Skip to content

Commit

Permalink
Added tut_06b
Browse files Browse the repository at this point in the history
  • Loading branch information
rbmetcalf committed Apr 2, 2024
1 parent add4749 commit 41929bc
Show file tree
Hide file tree
Showing 5 changed files with 779 additions and 12 deletions.
Binary file added tutorials/Lstare_estimates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/OGLE-detection-efficiency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/einstein_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 54 additions & 12 deletions tutorials/tut_06.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"\\end{array}\n",
"\\right)\n",
"\\end{equation}\n",
"The $y$'s in this case are the $D_L$'s. Now we need to weight by the errors. There doesn't seem to be a function for doing this automatically in python, but we can do it ourselves. If the dependent variables and the columns of the M matrix are divided by the standard deviations this will be equivalent to the chi-squared weighting as described in the lecture notes.\n",
"The $y$'s in this case are the $D_L$'s. Now we need to weight by the errors. There doesn't seem to be a function for doing this automatically in python, but we can do it ourselves. If the dependent variables and the columns of the M matrix are divided by the standard deviations this will be equivalent to the chi-squared weighting as described in the lecture notes (chapter 6, section 5).\n",
"\n",
"Fit a second order polynomial to $D_L$ vs $z$. Plot it and the data."
]
Expand Down Expand Up @@ -126,7 +126,7 @@
"\n",
"$q_o = \\frac{\\Omega_m}{2} - \\Omega_\\Lambda$\n",
"\n",
"where $\\Omega_m$ is the density of the Universe in ordinary matter in units of the critical density and $\\Omega_\\Lambda$ is the energy density of the cosmological constant in the same units.\n",
"where $\\Omega_m$ is the density of the Universe in ordinary matter in units of the critical density and $\\Omega_\\Lambda$ is the energy density of the cosmological constant in the same units. This is an approximation that was used for may years before observations extended out to $z>1$.\n",
"\n",
"If the Universe is geometrically flat $\\Omega_m+ \\Omega_\\Lambda = 1$ and \n",
"\n",
Expand Down Expand Up @@ -228,8 +228,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"7) Why might a person object to using a $\\chi^2_{n-2}$ distribution \n",
"above in determining the significance of the result?"
"~~7) Why might a person object to using a $\\chi^2_{n-2}$ distribution above in determining the significance of the result?~~"
]
},
{
Expand All @@ -251,7 +250,40 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"from scipy.stats import chi2\n",
"qo=np.linspace(...)\n",
"muo=np.linspace(...)\n",
"x2d,y2d = np.meshgrid(qo,muo)\n",
"\n",
"print(x2d.shape)\n",
"\n",
"X2 = np.zeros(x2d.shape)\n",
"for i in ... :\n",
" for j in ... :\n",
" X = ...\n",
"\n",
" X2[i,j] = np.dot(X,X)\n",
"\n",
"n = len(mu)\n",
"cl68 = ...\n",
"cl95 = ...\n",
"cl99 = ...\n",
"\n",
"fig, ax = plt.subplots()\n",
"CS = ax.contour(x2d,y2d,X2,[cl68,cl95,cl99])\n",
"\n",
"fmt = {}\n",
"strs = [ '68%', '95%', '99%']\n",
"for i,s in zip( CS.levels, strs ):\n",
" fmt[i] = s\n",
"\n",
"ax.clabel(CS, inline=True, fontsize=10,fmt=fmt)\n",
"\n",
"plt.xlabel(r'$q_o$')\n",
"plt.ylabel(r'$\\mu_o$')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
Expand All @@ -263,11 +295,9 @@
"\n",
"Make a nice histogram of the $q_o$ vector.\n",
"\n",
"This vector of $q_o$'s is approximately sampled from the true distribution. Find the mean and variance of this vector. This is an estimate of the variance in the estimate of $q_o$.\n",
"This vector of $q_o$'s is approximately sampled from the true distribution of possible data sets. Find the mean and variance of this vector. This is an estimate of the variance in the estimate of $q_o$.\n",
"\n",
"What is the measured value of $q_o$ with errors?\n",
"\n",
"Assuming the Universe is flat what is the measured value of $\\Omega_m$ with errors?"
"What is the measured value of $q_o$ with errors?\n"
]
},
{
Expand All @@ -276,7 +306,19 @@
"metadata": {},
"outputs": [],
"source": [
"### put loop here\n"
"### put loop here\n",
"\n",
"\n",
"### plot here\n",
"\n",
"print('qo = ', ... ,' +/- ', ... )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"10) Assuming the Universe is flat what is the measured value of $\\Omega_m$ with errors?"
]
},
{
Expand All @@ -285,11 +327,11 @@
"metadata": {},
"outputs": [],
"source": [
"### put plot here\n",
"### put plot here for flat case\n",
".\n",
".\n",
"\n",
"print('qo = ', ... ,' +/- ', ... )\n",
"\n",
"print('Omega_m = ', ... ,' +/- ', ... )\n"
]
},
Expand Down
725 changes: 725 additions & 0 deletions tutorials/tut_06b.ipynb

Large diffs are not rendered by default.

0 comments on commit 41929bc

Please sign in to comment.