Þ ¥bonds€¬cell_resultsÞ ¡Ù$daa349a6-545b-4dfc-a3b0-92884da98e5eЦqueued¤logs�§running¦output†¤bodyÚ G
Luminosity distance from Distance modulus
The standard definition of the distance modulus is $μ = 5 \log_{10}\left(\frac{d}{\mathrm{pc}}\right) - 5$ . We'll work in megaparsecs (Mpc), so we get $μ = 5 \log_{10}\left(\frac{d}{\mathrm{Mpc}}\right) + 25$ . Solving for $d$ gives $d = 10^{(\mu-25)/5}$ Since we're measuring distances based on the luminosity of supernovae, we're using a luminosity distance here. Hence I've included the subscript L.)
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8�E•°persist_js_state·has_pluto_hook_features§cell_idÙ$daa349a6-545b-4dfc-a3b0-92884da98e5e¹depends_on_disabled_cells§runtimeÎ :h¿µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$556d8f17-8a03-42c8-82c7-52c8125b604dЦqueued¤logs�§running¦output†¤bodyÚd
calc_mle_linear_model(A, y_obs, covar)
Computes the maximum likelihood estimator for θ for the linear model y = A θ where measurements errors of y_obs are normally distributed with covariance matrix covar about the true values of y.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœGµ§°persist_js_state·has_pluto_hook_features§cell_idÙ$556d8f17-8a03-42c8-82c7-52c8125b604d¹depends_on_disabled_cells§runtimeÎ ë¦Ãµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$77b17593-6a28-4294-9b17-41303d57d5a9Цqueued¤logs�§running¦output†¤bodyÙ%loss (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ8Î X°persist_js_state·has_pluto_hook_features§cell_idÙ$77b17593-6a28-4294-9b17-41303d57d5a9¹depends_on_disabled_cells§runtimeÎ Ø#µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2482544e-ad05-495c-9787-0797939445beЦqueued¤logs�§running¦output†¤bodyÙ¦¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ=ÊÔª°persist_js_state·has_pluto_hook_features§cell_idÙ$2482544e-ad05-495c-9787-0797939445be¹depends_on_disabled_cells§runtimeÎ)Jìµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$cd4fc36e-74f1-4b33-b92c-f0b7913a7203Цqueued¤logs�§running¦output†¤bodyÚß
It incorporated data from 833 supernovae (SNe), drawn from 19 datasets. Of these, 580 SNe passed usability cuts. We present new data from the HST Cluster Survey. All SNe were fit using a single lightcurve fitter (SALT2-1) and uniformly analyzed. All analyses and cuts were developed in a blind manner, i.e. with the cosmology hidden. The Union2.1 paper is available at Suzuki et al. (2012) .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ7Dú@°persist_js_state·has_pluto_hook_features§cell_idÙ$cd4fc36e-74f1-4b33-b92c-f0b7913a7203¹depends_on_disabled_cells§runtimeÎÛÝûµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0735d5d6-9328-47f7-a764-24b4b8d92ca3Цqueued¤logs�§running¦output†¤bodyÚpThe data are stored in a simple text file. There are many ways to read them. Julia has a fast reader for CSV files, so we'll demonstrate that below. For now, you don't need to pay attention to the syntax, but at some point you'll likely want to refer back to examples like this to see how to accomplish common tasks.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-[‘Ͱpersist_js_state·has_pluto_hook_features§cell_idÙ$0735d5d6-9328-47f7-a764-24b4b8d92ca3¹depends_on_disabled_cells§runtimeÎ fĵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$beeeb261-4dcb-4093-b1cd-08682785eadeЦqueued¤logs�§running¦output†¤bodyÚ=
Tip
What does abs2.(x) mean?
First, abs2(x) would return the squared absolute value of x. Second, when we're working with arrays rather than scalars, then we can specify element-wise arithmetic by adding a dot after a function name.
Similarly, we can add a dot before arithmetic operator (e.g., ./ instead of /) to specify element-wise arithmetic. (The difference is particularly important for multiplication when we need to distinguish between matrix-vector or matrix-matrix multiplication and element-wise multiplication.)
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8Îxÿ°persist_js_state·has_pluto_hook_features§cell_idÙ$beeeb261-4dcb-4093-b1cd-08682785eade¹depends_on_disabled_cells§runtimeÎ ª!µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9Цqueued¤logs�§running¦output†¤bodyƒ¤rowsœ’•’¨"1993ah"ªtext/plain’¨0.028488ªtext/plain’§8418.88ªtext/plain’§117.305ªtext/plain’§12.0956ªtext/plain’•’¨"1993ag"ªtext/plain’¨0.050043ªtext/plain’§14627.6ªtext/plain’§217.007ªtext/plain’§16.6721ªtext/plain’•’§"1993o"ªtext/plain’¨0.052926ªtext/plain’§15447.5ªtext/plain’§230.961ªtext/plain’§16.5664ªtext/plain’•’§"1993b"ªtext/plain’¨0.070086ªtext/plain’§20276.6ªtext/plain’§308.565ªtext/plain’§22.5181ªtext/plain’•’¨"1992bs"ªtext/plain’¨0.062668ªtext/plain’§18199.8ªtext/plain’§313.821ªtext/plain’§22.5595ªtext/plain’•’¨"1992br"ªtext/plain’¨0.087589ªtext/plain’§25112.6ªtext/plain’§442.396ªtext/plain’§38.2496ªtext/plain’•’¨"1992bp"ªtext/plain’¨0.078577ªtext/plain’§22633.9ªtext/plain’§314.509ªtext/plain’§22.5417ªtext/plain’•’¨"1992bo"ªtext/plain’¨0.017227ªtext/plain’§5120.05ªtext/plain’§85.2853ªtext/plain’§7.82903ªtext/plain’ •’¨"1992bl"ªtext/plain’¨0.042233ªtext/plain’§12394.0ªtext/plain’§185.051ªtext/plain’§14.2464ªtext/plain’
•’¨"1992bh"ªtext/plain’¨0.045295ªtext/plain’§13271.9ªtext/plain’§212.841ªtext/plain’§16.1709ªtext/plain¤more’ÍD•’§"Z-005"ªtext/plain’¥0.623ªtext/plain’©1.34805e5ªtext/plain’¦3183.5ªtext/plain’§353.947ªtext/plain¨objectid°891b6ee0b6c436fe¦schema‚¥names•¢id¡z¡v¤dâ‚—§Ïƒ_dâ‚—¥types•§String7§Float64§Float64§Float64§Float64¤mimeÙ"application/vnd.pluto.table+object¬rootassigneeÀ²last_run_timestampËAÙæœ:mt°persist_js_state·has_pluto_hook_features§cell_idÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¹depends_on_disabled_cells§runtimeÎŽ‚µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d19e7f11-d1ff-4624-8603-38ffec0c7beaЦqueued¤logs�§running¦output†¤bodyÙ7
Download the Data
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-[Yû°persist_js_state·has_pluto_hook_features§cell_idÙ$d19e7f11-d1ff-4624-8603-38ffec0c7bea¹depends_on_disabled_cells§runtimeÎ —/µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c6f03d5d-18e2-4491-90fe-fe0008f774c4Цqueued¤logs�§running¦output†¤bodyÚÎA diagonal matrix containing the squared measurement uncertainties, $\Sigma = \mathrm{diag}(\sigma_{d_{L}}^{2}) = \begin{bmatrix} \sigma_{d,1}^{-2} & & \\
& \sigma_{d,2}^{-2} & & \\
& & \ddots & \\
& & & \sigma_{d,N_{\mathrm{obs}}}^{-2} \end{bmatrix},$ and the design matrix contains the velocities $A = \left( \begin{matrix} v_1 \\
v_2 \\
... \\
v_{N_{\mathrm{obs}}} \end{matrix} \right).$ In this model, we're presuming that the velocities are known exactly. While this isn't technically true, the velocities are typically measured much more precisely than the distances, so it can be a reasonable approximation.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-n'-°persist_js_state·has_pluto_hook_features§cell_idÙ$c6f03d5d-18e2-4491-90fe-fe0008f774c4¹depends_on_disabled_cells§runtimeÎ î|µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$629dae3a-46ec-40dc-b9ed-92de9eb21adbЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8ÐÆ2°persist_js_state·has_pluto_hook_features§cell_idÙ$629dae3a-46ec-40dc-b9ed-92de9eb21adb¹depends_on_disabled_cells§runtimeÍ[•µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4518f1f7-a2a3-4783-86ae-4413fc4291b5Цqueued¤logs�§running¦output†¤bodyƒ¤rowsœ’•’¨"1993ah"ªtext/plain’¨0.028488ªtext/plain’§35.3466ªtext/plain’¨0.223906ªtext/plain’¨0.128419ªtext/plain’•’¨"1993ag"ªtext/plain’¨0.050043ªtext/plain’§36.6824ªtext/plain’¨0.166829ªtext/plain’¨0.128419ªtext/plain’•’§"1993o"ªtext/plain’¨0.052926ªtext/plain’§36.8177ªtext/plain’¨0.155756ªtext/plain’¨0.128419ªtext/plain’•’§"1993b"ªtext/plain’¨0.070086ªtext/plain’§37.4467ªtext/plain’¨0.158467ªtext/plain’¨0.128419ªtext/plain’•’¨"1992bs"ªtext/plain’¨0.062668ªtext/plain’§37.4834ªtext/plain’¨0.156099ªtext/plain’¨0.128419ªtext/plain’•’¨"1992br"ªtext/plain’¨0.087589ªtext/plain’§38.2291ªtext/plain’¨0.187746ªtext/plain’¨0.128419ªtext/plain’•’¨"1992bp"ªtext/plain’¨0.078577ªtext/plain’§37.4882ªtext/plain’¨0.155636ªtext/plain’¨0.128419ªtext/plain’•’¨"1992bo"ªtext/plain’¨0.017227ªtext/plain’§34.6544ªtext/plain’¨0.199337ªtext/plain’¨0.128419ªtext/plain’ •’¨"1992bl"ªtext/plain’¨0.042233ªtext/plain’§36.3365ªtext/plain’¨0.167174ªtext/plain’¨0.128419ªtext/plain’
•’¨"1992bh"ªtext/plain’¨0.045295ªtext/plain’§36.6403ªtext/plain’¨0.164981ªtext/plain’¨0.128419ªtext/plain¤more’ÍD•’§"Z-005"ªtext/plain’¥0.623ªtext/plain’§42.5145ªtext/plain’¨0.241428ªtext/plain’¨0.551672ªtext/plain¨objectid°a3fa5689f15fd2a8¦schema‚¥names•¢id¡z¢Î¼¥Ïƒ_μ±prob_low_mass_gal¥types•§String7§Float64§Float64§Float64§Float64¤mimeÙ"application/vnd.pluto.table+object¬rootassigneeÀ²last_run_timestampËAÙæœ8kˆÆ°persist_js_state·has_pluto_hook_features§cell_idÙ$4518f1f7-a2a3-4783-86ae-4413fc4291b5¹depends_on_disabled_cells§runtimeÎÊßrµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$e4597b96-6e06-44c2-a845-3d9967d2423cЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9Æç°persist_js_state·has_pluto_hook_features§cell_idÙ$e4597b96-6e06-44c2-a845-3d9967d2423c¹depends_on_disabled_cells§runtimeÍ^)µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8Цqueued¤logs�§running¦output†¤bodyÙÉAfter we've specified the general form of the statistcal model, we create a specific version of the model that is specialized for the valuse of the observations.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-rw)°persist_js_state·has_pluto_hook_features§cell_idÙ$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8¹depends_on_disabled_cells§runtimeÎ æIµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$6c86d0f1-5c6f-4204-9414-60577164f4b8Цqueued¤logs�§running¦output†¤body…¦prefixÙ¹DynamicPPL.Model{typeof(model_hubble_law_lognormal_prior), (:v, :d_obs, :σ_d_obs), (), (), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}}, Tuple{}, DynamicPPL.DefaultContext}¨elements”’¡f’ÙBmodel_hubble_law_lognormal_prior (generic function with 2 methods)ªtext/plain’¤args’ƒ¨elements“’¡v’…¦prefix§Float64¨elements—’’§8418.88ªtext/plain’’§14627.6ªtext/plain’’§15447.5ªtext/plain’’§20276.6ªtext/plain’’§18199.8ªtext/plain¤more’Í€’§57893.3ªtext/plain¤type¥Array¬prefix_short ¨objectid°cfe55747b0413d3eÙ!application/vnd.pluto.tree+object’¥d_obs’…¦prefix§Float64¨elements—’’§117.305ªtext/plain’’§217.007ªtext/plain’’§230.961ªtext/plain’’§308.565ªtext/plain’’§313.821ªtext/plain¤more’Í€’§1291.84ªtext/plain¤type¥Array¬prefix_short ¨objectid°14301e3138d6cedcÙ!application/vnd.pluto.tree+object’¨Ïƒ_d_obs’…¦prefix§Float64¨elements—’’§12.0956ªtext/plain’’§16.6721ªtext/plain’’§16.5664ªtext/plain’’§22.5181ªtext/plain’’§22.5595ªtext/plain¤more’Í€’§145.219ªtext/plain¤type¥Array¬prefix_short ¨objectid°6af18a9b6659a5c3Ù!application/vnd.pluto.tree+object¤typeªNamedTuple¨objectid°59d0421f6398110fÙ!application/vnd.pluto.tree+object’¨defaults’ƒ¨elements�¤typeªNamedTuple¨objectid°ffffffff412bd36eÙ!application/vnd.pluto.tree+object’§context’…¦prefix¹DynamicPPL.DefaultContext¨elements�¤type¦struct¬prefix_short®DefaultContext¨objectid°ffffffff9dc0ec1dÙ!application/vnd.pluto.tree+object¤type¦struct¬prefix_short¥Model¨objectid°d30f1722f056fac0¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÙ+model_hubble_law_lognormal_prior_given_data²last_run_timestampËAÙæœF@®!°persist_js_state·has_pluto_hook_features§cell_idÙ$6c86d0f1-5c6f-4204-9414-60577164f4b8¹depends_on_disabled_cells§runtimeÎ LÄUµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a7981271-0b12-4b75-b5f0-5e91af761419Цqueued¤logs�§running¦output†¤bodyÚÚIn this case, we had a very simple model and the linear algebra was straight forward. In more complicated cases, there could be many input variables (here velocity), multiple observables being predicted (here distance), correlations between the different observables, and many possible models to try. Setting up all the matrices and getting all the algebra right for each model is error prone. Therefore, most modern high-level programming languages have packages that make it easy to fit linear models such as this one. Below, we'll repeat the analysis, but using Julia's GLM.jl package for general linear models.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-nÆÁ°persist_js_state·has_pluto_hook_features§cell_idÙ$a7981271-0b12-4b75-b5f0-5e91af761419¹depends_on_disabled_cells§runtimeÎ ·µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$276a850b-09da-41f0-8661-5d63bb2afdf8Цqueued¤logs˜ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¨progress’§nothingªtext/plain¢idÙ$9d4c1fcd-68ed-4703-8f97-7888804b2bff¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’·Found initial step sizeªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¢Ïµ’£0.2ªtext/plain¢id¹Turing_Inference_9f2c9803¤fileÙ9/home/runner/.julia/packages/Turing/NQDYt/src/mcmc/hmc.jl¥group£hmc¥level¤Infoˆ¤lineÿ£msg’·Found initial step sizeªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¢Ïµ’¥0.025ªtext/plain¢id¹Turing_Inference_9f2c9803¤fileÙ9/home/runner/.julia/packages/Turing/NQDYt/src/mcmc/hmc.jl¥group£hmc¥level¤Infoˆ¤lineÿ£msg’·Found initial step sizeªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¢Ïµ’£0.4ªtext/plain¢id¹Turing_Inference_9f2c9803¤fileÙ9/home/runner/.julia/packages/Turing/NQDYt/src/mcmc/hmc.jl¥group£hmc¥level¤Infoˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¨progress’²0.3333333333333333ªtext/plain¢idÙ$9d4c1fcd-68ed-4703-8f97-7888804b2bff¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¨progress’²0.6666666666666666ªtext/plain¢idÙ$9d4c1fcd-68ed-4703-8f97-7888804b2bff¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¨progress’£1.0ªtext/plain¢idÙ$9d4c1fcd-68ed-4703-8f97-7888804b2bff¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¦kwargs‘’¨progress’¦"done"ªtext/plain¢idÙ$9d4c1fcd-68ed-4703-8f97-7888804b2bff¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœB´ïذpersist_js_state·has_pluto_hook_features§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¹depends_on_disabled_cells§runtimeÏ ¬µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974bЦqueued¤logs�§running¦output†¤bodyȼ
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœ:¬3�°persist_js_state·has_pluto_hook_features§cell_idÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974b¹depends_on_disabled_cells§runtimeÎÀIlµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0236d055-0d6d-440d-a44b-0d5cb0ab2273Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_2b²last_run_timestampËAÙæœ:?[«°persist_js_state·has_pluto_hook_features§cell_idÙ$0236d055-0d6d-440d-a44b-0d5cb0ab2273¹depends_on_disabled_cells§runtimeÍ06µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$efde0b1e-ec47-4180-aba7-ed8843395b50Цqueued¤logs�§running¦output†¤bodyÙÄQ1c: Use the slider below to try different values of $H_0$ . Approximately what value looks like the best-fit to you?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-mÔ°persist_js_state·has_pluto_hook_features§cell_idÙ$efde0b1e-ec47-4180-aba7-ed8843395b50¹depends_on_disabled_cells§runtimeÎ $Wµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$48e246bc-4937-40d6-b686-73524f3ce057Цqueued¤logs�§running¦output†¤bodyÙ=
Setup & Helper Code
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-wõ^°persist_js_state·has_pluto_hook_features§cell_idÙ$48e246bc-4937-40d6-b686-73524f3ce057¹depends_on_disabled_cells§runtimeÎ Ïxµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2786b37a-207f-4831-983e-81a380c37045Цqueued¤logs�§running¦output†¤bodyÚªIf one puts in a fair bit of algebra, then one can find an analytical expression for the value of the model parameters ($\theta$ ) that minimizes the likelihood for a linear model.
You're likely to see the derivation of the solution in class on staistics (or maybe linear algebra), but we'll just use the result:
$$\hat{\theta} = (A' \Sigma^{-1} A)^{-1} (A' \Sigma^{-1} \ y_\mathrm{obs} ),$$
where $y_{\mathrm{obs}}$ is the vector of measurement values, $\Sigma^{-1}$ is the covariance matrix, and $A$ is the design matrix . For our problem, these simplify to:
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-móǰpersist_js_state·has_pluto_hook_features§cell_idÙ$2786b37a-207f-4831-983e-81a380c37045¹depends_on_disabled_cells§runtimeÎ Fzµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70eЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ:�ˆ°persist_js_state·has_pluto_hook_features§cell_idÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70e¹depends_on_disabled_cells§runtimeάÌJµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d3e82a29-c1b5-4f5a-ba96-a64d22636493Цqueued¤logs�§running¦output†¤bodyÚNotice that this code is very different from a tradditional program where we'd specify how to compute each variable in order (known as the imperative programming model).
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-rCx°persist_js_state·has_pluto_hook_features§cell_idÙ$d3e82a29-c1b5-4f5a-ba96-a64d22636493¹depends_on_disabled_cells§runtimeÎ ÈBµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$49090825-2843-4b3e-8ee6-658187232f96Цqueued¤logs�§running¦output†¤bodyÙE
Sensitivity to Choice of Priors
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-sK°persist_js_state·has_pluto_hook_features§cell_idÙ$49090825-2843-4b3e-8ee6-658187232f96¹depends_on_disabled_cells§runtimeÎ =qµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$e0e610d7-a237-42ea-8706-8e09858fba03Цqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ:C^°persist_js_state·has_pluto_hook_features§cell_idÙ$e0e610d7-a237-42ea-8706-8e09858fba03¹depends_on_disabled_cells§runtimeÍ]tµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0aЦqueued¤logs�§running¦output†¤bodyÈÎ
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœHr÷Y°persist_js_state·has_pluto_hook_features§cell_idÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0a¹depends_on_disabled_cells§runtimeÎ4Ù?µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1d70572f-214e-4161-b804-2c3b7c077c56Цqueued¤logs�§running¦output†¤body²0.1942240146235329¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœH?¿°persist_js_state·has_pluto_hook_features§cell_idÙ$1d70572f-214e-4161-b804-2c3b7c077c56¹depends_on_disabled_cells§runtimeÍÛ[µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$23ee2544-2a2f-4302-8a62-2dd868cbb5d1Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_2d²last_run_timestampËAÙæœ:Ae°persist_js_state·has_pluto_hook_features§cell_idÙ$23ee2544-2a2f-4302-8a62-2dd868cbb5d1¹depends_on_disabled_cells§runtimeÍ-ɵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$69ca76b8-8766-47fe-89d6-31fcc7a60e88Цqueued¤logs�§running¦output†¤body¡0¤mimeªtext/plain¬rootassignee«response_1f²last_run_timestampËAÙæœ9¤L°persist_js_state·has_pluto_hook_features§cell_idÙ$69ca76b8-8766-47fe-89d6-31fcc7a60e88¹depends_on_disabled_cells§runtimeÍ1Gµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$18106638-c96c-47d6-990d-b35b6b0ba218Цqueued¤logs�§running¦output†¤bodyÙíSelect type of plot to show: histogram density
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9%õè°persist_js_state·has_pluto_hook_features§cell_idÙ$18106638-c96c-47d6-990d-b35b6b0ba218¹depends_on_disabled_cells§runtimeÎ
�5µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$f90594d8-92a1-4b0b-93d0-0e41e76b3f55Цqueued¤logs�§running¦output†¤bodyÚvQ1e: How does the best-fit value computed above compare to your previous estimate based on the plot of $\chi^2$ vs $H_0$ ? What is likely to explain any differences?
Does Hubble's law provide a good model for these observations? If not, explain your concern.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-n‘y°persist_js_state·has_pluto_hook_features§cell_idÙ$f90594d8-92a1-4b0b-93d0-0e41e76b3f55¹depends_on_disabled_cells§runtimeÎ xµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$aaa80da1-f7de-42ed-9691-c367e6bd9a28Цqueued¤logs�§running¦output†¤bodyÚMŒ
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ6ÿ÷°persist_js_state·has_pluto_hook_features§cell_idÙ$aaa80da1-f7de-42ed-9691-c367e6bd9a28¹depends_on_disabled_cells§runtimeÍ3µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ9 N×°persist_js_state·has_pluto_hook_features§cell_idÙ$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18¹depends_on_disabled_cells§runtimeÍ`3µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$92ca099c-b81b-4cfe-a3fa-60833657f4efЦqueued¤logs�§running¦output†¤bodyÚ¡The Hubble "law" ($v = H_0 \times d$ ) for the expansion of the universe is based on velocity versus distance. That's not what this data file provided, but we can compute those using standard expressions that you may have seen in an introduction to astronomy class. You learn or refresh your memory about each by clicking below.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-\±«°persist_js_state·has_pluto_hook_features§cell_idÙ$92ca099c-b81b-4cfe-a3fa-60833657f4ef¹depends_on_disabled_cells§runtimeÎ ;êµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$03fc47ea-9246-4cb8-8398-612fc2fb09faЦqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1b²last_run_timestampËAÙæœ8›^W°persist_js_state·has_pluto_hook_features§cell_idÙ$03fc47ea-9246-4cb8-8398-612fc2fb09fa¹depends_on_disabled_cells§runtimeÍ0µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48Цqueued¤logs�§running¦output†¤bodyÙBmodel_hubble_law_lognormal_prior (generic function with 2 methods)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ:>±)°persist_js_state·has_pluto_hook_features§cell_idÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48¹depends_on_disabled_cells§runtimeÎR¾Ê�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9db3ff24-6f54-4a37-b787-de4b14694d95Цqueued¤logs�§running¦output†¤bodyÚ
calc_fisher_matrix_linear_model
calc_fisher_matrix_linear_model(A, covar)
Computes the Fisher information matrix for θ for the linear model y = A θ where measurements errors of y_obs are normally distributed and have covariance covar. Note that y_obs is not passed to this function, because it does not affect results.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœHÀ3°persist_js_state·has_pluto_hook_features§cell_idÙ$9db3ff24-6f54-4a37-b787-de4b14694d95¹depends_on_disabled_cells§runtimeÎ !(µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c6af6d4a-ff58-4012-b4b2-4e3b09d53638Цqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9·™°persist_js_state·has_pluto_hook_features§cell_idÙ$c6af6d4a-ff58-4012-b4b2-4e3b09d53638¹depends_on_disabled_cells§runtimeÍ[‰µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572Цqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8›èl°persist_js_state·has_pluto_hook_features§cell_idÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572¹depends_on_disabled_cells§runtimeÍgRµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b15b1913-d265-4a35-b43e-67df53c93329Цqueued¤logs�§running¦output†¤bodyÚL
How to access metadata
You can access the metadata from a DataFrame using function calls like metadata(df_in) or colmetadata(df_in,:z).
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8Šá‚°persist_js_state·has_pluto_hook_features§cell_idÙ$b15b1913-d265-4a35-b43e-67df53c93329¹depends_on_disabled_cells§runtimeÎ ¶Ü;µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4655178c-a633-4b50-8f92-6ee028e21d0eЦqueued¤logs�§running¦output†¤bodyÙD
Apply Variable Transformations
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-\—Õ°persist_js_state·has_pluto_hook_features§cell_idÙ$4655178c-a633-4b50-8f92-6ee028e21d0e¹depends_on_disabled_cells§runtimeÎ öµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3bdb27da-451c-4260-bf43-5568985d24f2Цqueued¤logs�§running¦output†¤bodyÚ\As we develop more complex models, it will often not be practical to find the maximum likelihood estimator values analyticly or using a general linear modeling package. Or there may be significant prior knowledge that we'd like to incorporate into our analysis. Or we might want to perform a more rigorous analysis of the uncertainties on the model parameters. In any of these cases, it can be very useful to use a probabilistic modeling language (PPL), such as Turing or Stan .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-rÕ°persist_js_state·has_pluto_hook_features§cell_idÙ$3bdb27da-451c-4260-bf43-5568985d24f2¹depends_on_disabled_cells§runtimeÎ —µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2f7c11e8-d429-41eb-873e-ae554e028195Цqueued¤logs�§running¦output†¤bodyÙ¤Q1a: Is this plot consistent with your expectations for velocity versus distance? If not, what surprised you?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-]Õ°persist_js_state·has_pluto_hook_features§cell_idÙ$2f7c11e8-d429-41eb-873e-ae554e028195¹depends_on_disabled_cells§runtimeÎ °µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$8764ccfe-81cd-4bff-985a-c112fc5c902fЦqueued¤logs�§running¦output†¤bodyÚFQ2a: How do the mean and standard deviation for the Hubble constant estimated with our Bayesian model and Turing compare to the analytic estimates using linear model (and the same dataset)? Are any differences large or small compare to the reported uncertainties?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-rêͰpersist_js_state·has_pluto_hook_features§cell_idÙ$8764ccfe-81cd-4bff-985a-c112fc5c902f¹depends_on_disabled_cells§runtimeÎ ¦µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b7e2903b-be56-4e36-885f-e16a9ddc94c6Цqueued¤logs�§running¦output†¤bodyÚThis value is nothing like what we got above. Why? Remember that to write this in a form ammenable to the analytic solution, we predicted distances based on velocities $d = v / H_0$ , so the best-fit constant of proportionality is the recipocal of $H_0$ . Let's transform that back to a best-fit value for the Hubble constant, $\hat{H_0}_{,bf} = 1/\hat{\theta}_{bf}$ .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-ns°persist_js_state·has_pluto_hook_features§cell_idÙ$b7e2903b-be56-4e36-885f-e16a9ddc94c6¹depends_on_disabled_cells§runtimeÎ QIµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_2a²last_run_timestampËAÙæœ9&¦n°persist_js_state·has_pluto_hook_features§cell_idÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264¹depends_on_disabled_cells§runtimeÍ;þµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$089c50b6-5494-4f27-af3e-a8af972e2869Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_2c²last_run_timestampËAÙæœ:@aí°persist_js_state·has_pluto_hook_features§cell_idÙ$089c50b6-5494-4f27-af3e-a8af972e2869¹depends_on_disabled_cells§runtimeÍ-µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709Цqueued¤logs�§running¦output†¤bodyÚ
You likely noticed that Hubble's "Law" wasn't a great model for this dataset. That's because it's an incomplete model that works well in the local universe, but breaks down once astronomers look far enough away that we can see the effects of dark energy causing the rate of expansion to accelerate. If we want to measure the local Hubble constant, then we could fit a subset of our dataset, picking those SN that have velocities less than some threshold.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-pÜn°persist_js_state·has_pluto_hook_features§cell_idÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709¹depends_on_disabled_cells§runtimeÎ '"µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6Цqueued¤logs�§running¦output†¤bodyÚ
For the above model, then likelihood is given by
$$\mathcal{L} = \frac{1}{\sqrt{(2\pi)^{N_{\mathrm{obs}}} \prod_{i=1}^{N_{\mathrm{obs}}} \sigma_{d,i}^2} } \; e^{-\chi^2/2}$$
Minimizing $\mathcal{L}$ is equivalent to minimizing $\ell = \log(\mathcal{L})$ . Since the first factor doesn't depend on the measured values of distance, we can minimize $\mathcal{L}$ and $\ell$ by minimizing $\chi^2$ .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-m¶R°persist_js_state·has_pluto_hook_features§cell_idÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6¹depends_on_disabled_cells§runtimeÎ 9pµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a56871c9-affa-4612-b3f5-66363720f274Цqueued¤logs�§running¦output†¤bodyÙOand we can compute some summary statistics.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-rÉT°persist_js_state·has_pluto_hook_features§cell_idÙ$a56871c9-affa-4612-b3f5-66363720f274¹depends_on_disabled_cells§runtimeÎ ãÛµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4f27d8d1-0d14-49e5-abee-9f277369a78bЦqueued¤logs�§running¦output†¤bodyÙ@model_hubble_law_uniform_prior (generic function with 2 methods)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ:V¢U°persist_js_state·has_pluto_hook_features§cell_idÙ$4f27d8d1-0d14-49e5-abee-9f277369a78b¹depends_on_disabled_cells§runtimeÎ S4ñµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0144843f-b649-4ea2-a546-e8c14a928670Цqueued¤logs�§running¦output†¤bodyÚ[Q2b: How do the estimates of the posterior mean and standard deviation using two different choices for the prior compare to each other? Are any differences large or small compare to the reported uncertainties? What does this imply about the sensitivity of our analysis to the choice of prior?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-sUC°persist_js_state·has_pluto_hook_features§cell_idÙ$0144843f-b649-4ea2-a546-e8c14a928670¹depends_on_disabled_cells§runtimeÎ ñ”µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a7d8f517-4117-4585-8089-117510c944c5Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ:N°persist_js_state·has_pluto_hook_features§cell_idÙ$a7d8f517-4117-4585-8089-117510c944c5¹depends_on_disabled_cells§runtimeÍ2¸µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$18dd7cac-fac3-4c40-9230-f6387e41751bЦqueued¤logs�§running¦output†¤bodyÙçQ1b: Do you notice anything potentially concerning about the plot? If so, describe your concerns. Optionally, use the cell below to perform any tests to address your concerns.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-]ð¢°persist_js_state·has_pluto_hook_features§cell_idÙ$18dd7cac-fac3-4c40-9230-f6387e41751b¹depends_on_disabled_cells§runtimeÎ ŒÏµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$fa745b36-7465-443e-9f50-c786fe418c6aЦqueued¤logs�§running¦output†¤bodyÚE580×580 PDiagMat{Float64, Vector{Float64}}:
146.304 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0
0.0 277.959 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 274.446 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 507.065 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 508.93 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
⋮ ⋱
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 2.28313e5 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 8.35542e6 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.25279e5¤mimeªtext/plain¬rootassignee¦Î£_all²last_run_timestampËAÙæœ:ߦ°persist_js_state·has_pluto_hook_features§cell_idÙ$fa745b36-7465-443e-9f50-c786fe418c6a¹depends_on_disabled_cells§runtimeÎê/@µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82Цqueued¤logs�§running¦output†¤bodyÚˆStatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Vector{Float64}}, GLM.DensePredChol{Float64, CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}}}, Matrix{Float64}}
dâ‚— ~ 0 + v
Coefficients:
───────────────────────────────────────────────────────────────
Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
───────────────────────────────────────────────────────────────
v 0.0174856 0.00402163 4.35 0.1305 -0.0258353 0.0608065
───────────────────────────────────────────────────────────────¤mimeªtext/plain¬rootassignee§wls_all²last_run_timestampËAÙæœ=ÆØ€°persist_js_state·has_pluto_hook_features§cell_idÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82¹depends_on_disabled_cells§runtimeÎ
KÑ«µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6Цqueued¤logs�§running¦output†¤bodyÚ Q
Probabilistic Programming Languages
Traditionally, programmers provide explicit instructions for what steps the program should perform in what order (known as the imperative programming model). But there are alternatives. For example, probabilistic programming languages (PPLs) allow programmers to specify target probability distributions to be computed (or sampled from), without specifying how to perform inference with that target distribution. In this exercise, we'll demonstrate how to use the Turing.jl PPL. Turing is implemented entirely in Julia and is highly composable, so that one can perform inference with complex models written in Julia. In this notebook, we'll demonstrate applying it to the simple model for the Hubble expansion.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9
÷°persist_js_state·has_pluto_hook_features§cell_idÙ$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6¹depends_on_disabled_cells§runtimeÎ áMµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c433e938-31f7-4417-b3c0-a2f49fea8640Цqueued¤logs�§running¦output†¤bodyÙ¹¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9â“°persist_js_state·has_pluto_hook_features§cell_idÙ$c433e938-31f7-4417-b3c0-a2f49fea8640¹depends_on_disabled_cells§runtimeÎ …‰•µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3aba1134-7c60-41f6-a1ac-73306efb7824Цqueued¤logs�§running¦output†¤bodyÚHGoodness-of-fit statistic
Usually, we don't know the true value of all our model's parameters (in this case the Hubble constant). Therefore, we want to use astronomical data to measure (or more generally to improve our knowldge of) the model parameters. For any value of the model parameter(s), we can compute the residuals between the observations and the model predicitons, $\Delta_i = d_i - v_{\mathrm{obs},i}/H_0$ .
If the model and model parameters were the perfect truth, then $\Delta_i \sim \mathrm{Normal}(0,\sigma_i^2).$
Even if the model isn't perfect, we can compute a goodness-of-fit statistic ,
$$\chi^2 = \sum_{i=1}^{N_\mathrm{obs}} \Delta_i^2.$$
If the model is perfect, then $\chi^2 = \sum_{i=1}^{N_\mathrm{obs}} \Delta_i^2/\sigma_i^2$ and its expected value becomes
$$E\left[\sum_{i=1}^{N_\mathrm{obs}} \Delta_i^2/\sigma_i^2 \right] = N_{\mathrm{obs}},$$
since $E[\Delta_i^2/\sigma_i^2] = 1$ for each $i$ .
If we evaluate $\chi^2$ using model parameters that differ from the truth, then the expected value of the value of $\chi^2$ statistic increases. We can find the value of the model parameters than minimize $\chi^2$ to provide us with the best-fit model.
This model for observations is so common that statistican have given a name to the probabilitiy distribution that the $\chi^2$ statistic follows... the $\chi^2$ distribution .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-lôˆ°persist_js_state·has_pluto_hook_features§cell_idÙ$3aba1134-7c60-41f6-a1ac-73306efb7824¹depends_on_disabled_cells§runtimeÎ ó¿µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$5e635a20-e205-48f0-908d-cb6d0c55b43bЦqueued¤logs�§running¦output†¤bodyÙL
Bayesian Inference with a Linear Model
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-qä�°persist_js_state·has_pluto_hook_features§cell_idÙ$5e635a20-e205-48f0-908d-cb6d0c55b43b¹depends_on_disabled_cells§runtimeÎ »µµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8Цqueued¤logs�§running¦output†¤body²0.2256856523900695¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœHE`¯°persist_js_state·has_pluto_hook_features§cell_idÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8¹depends_on_disabled_cells§runtimeÎ C%µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7be54420-b2ec-4ef4-adc8-848817305d07Цqueued¤logs�§running¦output†¤bodyÙD
Injests & Prepare the Data
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-ZSX°persist_js_state·has_pluto_hook_features§cell_idÙ$7be54420-b2ec-4ef4-adc8-848817305d07¹depends_on_disabled_cells§runtimeÎ ²�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$16b0a2c1-5803-4310-9ee7-884b1333fb74Цqueued¤logs�§running¦output†¤bodyÙëQ1h: Which dataset do you think provides a better estimate of the Hubble constant? Why? For which dataset is the formal measurement uncertainty larger? Explain your why that is.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-q°u°persist_js_state·has_pluto_hook_features§cell_idÙ$16b0a2c1-5803-4310-9ee7-884b1333fb74¹depends_on_disabled_cells§runtimeÎ ”üµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0c20b9a7-69a9-49c8-9ba4-45b8770393d0Цqueued¤logs�§running¦output†¤bodyÚ‘Use the slider below to pick a threshold velocity below which the model of a linear releationship between $v$ and $d$ appears to be accurate. The figure will automatically update to show only the data you've selected and the predictions with the best-fit $H_0$ for that subset of data.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-põذpersist_js_state·has_pluto_hook_features§cell_idÙ$0c20b9a7-69a9-49c8-9ba4-45b8770393d0¹depends_on_disabled_cells§runtimeÎ }Zµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ5?FÔ°persist_js_state·has_pluto_hook_features§cell_idÙ$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9¹depends_on_disabled_cells§runtimeÏ XåÁ|µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d70d95e9-f0e7-4225-8e06-80735278cbcaЦqueued¤logs�§running¦output†¤bodyÚZ¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8Å®>°persist_js_state·has_pluto_hook_features§cell_idÙ$d70d95e9-f0e7-4225-8e06-80735278cbca¹depends_on_disabled_cells§runtimeÎ
¶®µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5bЦqueued¤logs�§running¦output†¤bodyÚ[
By definition $1+z = \sqrt{\frac{c+v}{c-v}},$ where $c$ is the speed of light. Solving for $v$ gives $v = c - \frac{2c}{(1+z)^2+1}$ .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8�{J°persist_js_state·has_pluto_hook_features§cell_idÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5b¹depends_on_disabled_cells§runtimeÎ ÷ðµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$22da4ae4-6aea-4d45-ab2c-6fe935783e41Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1h²last_run_timestampËAÙæœ9°persist_js_state·has_pluto_hook_features§cell_idÙ$22da4ae4-6aea-4d45-ab2c-6fe935783e41¹depends_on_disabled_cells§runtimeÍ,øµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a8f89fe8-110b-452e-9ecb-53769aa02a2eЦqueued¤logs�§running¦output†¤bodyÚèOverview
In this lab, we'll measure the Hubble constant ($H_0$ ), the rate of expansion of the local universe using observations of Type 1a Supernovae. First, we'll download and read data from the Supernovae Cosmology Project and do a few transformations, so that we can plot velocity versus distance. Second, we'll develop a statistical model to describe our data based on our understanding of the astrophysics and measurement process. We'll compute the maximum likelihood estimate for the model parameters using conventional linear algebra techniques. This is a very useful and common method. (I'd say its analogous the harmonic oscillator in physics!) Next, we'll preview multiple other ways we could have fit the same model, but using different techniques. You'll think about some of the results as we go and the advantages/disadvantages/limitations of each approach.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-Y2ä°persist_js_state·has_pluto_hook_features§cell_idÙ$a8f89fe8-110b-452e-9ecb-53769aa02a2e¹depends_on_disabled_cells§runtimeÎ 5mµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a01c7aad-429d-447b-8943-a4e89dbac6f6Цqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ:Aò°persist_js_state·has_pluto_hook_features§cell_idÙ$a01c7aad-429d-447b-8943-a4e89dbac6f6¹depends_on_disabled_cells§runtimeÍ^„µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3Цqueued¤logs˜ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¨progress’§nothingªtext/plain¢idÙ$b034b2e3-a5ed-40bf-9c7c-a8452c4e26ae¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’·Found initial step sizeªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¢Ïµ’ª0.00078125ªtext/plain¢id¹Turing_Inference_9f2c9803¤fileÙ9/home/runner/.julia/packages/Turing/NQDYt/src/mcmc/hmc.jl¥group£hmc¥level¤Infoˆ¤lineÿ£msg’·Found initial step sizeªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¢Ïµ’«9.765625e-5ªtext/plain¢id¹Turing_Inference_9f2c9803¤fileÙ9/home/runner/.julia/packages/Turing/NQDYt/src/mcmc/hmc.jl¥group£hmc¥level¤Infoˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¨progress’²0.3333333333333333ªtext/plain¢idÙ$b034b2e3-a5ed-40bf-9c7c-a8452c4e26ae¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’·Found initial step sizeªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¢Ïµ’«0.000390625ªtext/plain¢id¹Turing_Inference_9f2c9803¤fileÙ9/home/runner/.julia/packages/Turing/NQDYt/src/mcmc/hmc.jl¥group£hmc¥level¤Infoˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¨progress’²0.6666666666666666ªtext/plain¢idÙ$b034b2e3-a5ed-40bf-9c7c-a8452c4e26ae¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¨progress’£1.0ªtext/plain¢idÙ$b034b2e3-a5ed-40bf-9c7c-a8452c4e26ae¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)ˆ¤lineÿ£msg’´Sampling (2 threads)ªtext/plain§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¦kwargs‘’¨progress’¦"done"ªtext/plain¢idÙ$b034b2e3-a5ed-40bf-9c7c-a8452c4e26ae¤fileÙI/home/runner/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl¥group¯ProgressLogging¥level¬LogLevel(-1)§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœG‚àÛ°persist_js_state·has_pluto_hook_features§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¹depends_on_disabled_cells§runtimeÏ
Ùi¸µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$098afd51-2c39-42ef-91bf-cfc326827ea1Цqueued¤logs�§running¦output†¤bodyÚ,Q1d: Based on the figure above, what would you estiamte for the best-fit value of $H_0$ ? How did your previous estimate of the best-fit value for $H_0$ compare to the minimum in the figure above?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-m~‘°persist_js_state·has_pluto_hook_features§cell_idÙ$098afd51-2c39-42ef-91bf-cfc326827ea1¹depends_on_disabled_cells§runtimeÎ Ìóµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bcЦqueued¤logs�§running¦output†¤bodyÉ ˆ
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœH”Là°persist_js_state·has_pluto_hook_features§cell_idÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bc¹depends_on_disabled_cells§runtimeÎdDµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479Цqueued¤logs�§running¦output†¤bodyÙ£Now we can easily compute & plot the $\chi^2$ as a function of the value of the Hubble parameter.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-mb_°persist_js_state·has_pluto_hook_features§cell_idÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479¹depends_on_disabled_cells§runtimeÎ t•µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56dЦqueued¤logs�§running¦output†¤bodyÙS
Quantifying Uncertainties in Model Parameters
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-qE·°persist_js_state·has_pluto_hook_features§cell_idÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56d¹depends_on_disabled_cells§runtimeΠ¿µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4Цqueued¤logs�§running¦output†¤body±31.98215264395374¤mimeªtext/plain¬rootassignee¬Hâ‚€_ols_all²last_run_timestampËAÙæœ=³¯Ÿ°persist_js_state·has_pluto_hook_features§cell_idÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4¹depends_on_disabled_cells§runtimeÍP:µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$42366f09-d437-4ba2-93ec-f7b8278eb09dЦqueued¤logs�§running¦output†¤bodyÙýQ1i: Is the difference between the best-fit values for the two datasets larger or smaller than the formal uncertainty estimates? What does that imply for the true uncertainty in the Hubble constant?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-q˰°persist_js_state·has_pluto_hook_features§cell_idÙ$42366f09-d437-4ba2-93ec-f7b8278eb09d¹depends_on_disabled_cells§runtimeÎ Èεpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d0f003fa-f72d-4a6f-ba60-1cad3844ef6aЦqueued¤logs�§running¦output†¤bodyÚ¬In the function model_hubble_law_uniform_prior, we specified the probability distribution for each random variable using the syntax variable ~ distribution. For example, we specified the prior for $H_0$ and the likelihood, $\mathcal{L} = p(d_{\mathrm{obs}} | d_{\mathrm{true}}, σ_d)$ . We specify how the true distance can be computed from the velocity and Hubble constant, but we . The input arguements for the model are the data to be analyzed, including $d_\mathrm{obs}$ . But we won't specify a value for $H_0$ or the values of $d_\mathrm{true}$ . The computer will figure out the distributions implied for both of these variables given the data we provide.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-r^p°persist_js_state·has_pluto_hook_features§cell_idÙ$d0f003fa-f72d-4a6f-ba60-1cad3844ef6a¹depends_on_disabled_cells§runtimeÎ 0µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$f0220da0-6f3a-438c-b533-acb346382418Цqueued¤logs�§running¦output†¤bodyÚ
Ready for an explanation of the syntax above?
Before we can use Julia's CSV reader, first we need to load the CSV.jl package. That's done at the bottom of the notebook with the command using CSV. Then we can call the function CSV.read(...). The first two function arguements specify the filename and that we should read the data into a DataFrame. The remaining arguements are option and allow us to fine-tune the behavior of the CSV reader. This data file used tabs (written using the escaple code \t) to separate the columns rather than the standard commas, so we had to specify that with the optional delim parameter. Additionally, the file included some comments/metadata in the first five rows, so we had to tell the CSV reader to skip to row 6 using the optional skipto parameter. Finally, the file didn't include column heading, so we provided those manually.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8m’°°persist_js_state·has_pluto_hook_features§cell_idÙ$f0220da0-6f3a-438c-b533-acb346382418¹depends_on_disabled_cells§runtimeÎ Ã[µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$8bfe0413-782b-4244-8624-a9f95e393d17Цqueued¤logs�§running¦output†¤bodyÚ÷Packages like GLM.jl allow us to specify a model with a modeling language . The compiler figures out how to build the matrices and what calculations to peform in order to compute the MLEs. The simplest possible model formula is d ~ v meaning the distance is proportional to velocity (the constant to be fit is implicit). We then call the lm function to return the best fit model for a given model and dataset.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-pJ°persist_js_state·has_pluto_hook_features§cell_idÙ$8bfe0413-782b-4244-8624-a9f95e393d17¹depends_on_disabled_cells§runtimeÎ P¥µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3ec3e49c-04ce-4ffa-b1ca-8c58df0307ddЦqueued¤logs�§running¦output†¤bodyÚ+In the figure above, the vertical line indicates the best-fit value for each dataset and the the horizontal bar shows the the measurement uncertainty for each dataset. We could estimate the uncertainties by calculating the second derivative of the log likelihood.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-qxȰpersist_js_state·has_pluto_hook_features§cell_idÙ$3ec3e49c-04ce-4ffa-b1ca-8c58df0307dd¹depends_on_disabled_cells§runtimeÎ ;rµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$92238689-d9df-46c2-bd72-3fcc41a22594Цqueued¤logs�§running¦output†¤bodyÚ%The output table provides the best-fit value for each of the parameters in the linear model. In this case there is the the coefficient to v ($1/H_0$ ) as well as an intercept. That's because it fit the model $d = c_v v + c_{\mathrm{intercept}}$ , rather than just $d = c_v v$ . We can tell it that we don't want to include an intercept using the model formula dâ‚— ~ 0 + v.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-pf4°persist_js_state·has_pluto_hook_features§cell_idÙ$92238689-d9df-46c2-bd72-3fcc41a22594¹depends_on_disabled_cells§runtimeÎ ¬[µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d5c3923b-8515-4002-9d93-6768f087aef6Цqueued¤logs�§running¦output†¤bodyÚÉQ2c: Given your findings above, which of the following choices is likely to have the most significant effect on your measurement of the Hubble constant?
Choice of supernovae to be included in analysis
Choice of whether to estimate $H_0$ with an MLE or MAP estimator
Choice of prior for $H_0$
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-wŸ€°persist_js_state·has_pluto_hook_features§cell_idÙ$d5c3923b-8515-4002-9d93-6768f087aef6¹depends_on_disabled_cells§runtimeÎ ç[µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4f11d0e2-7126-47f1-865a-3474298597dcЦqueued¤logs�§running¦output†¤bodyÚEWhen using a PPL like Turing, we need to specify a prior distribution for each model parameter and the likelihood function describing how the observations are generated from the model. For example, we could adopt a Normal prior for $H_0$ :
$$H_0 \sim \mathrm{Normal}(0,\sigma_{pr,H_0}^2)$$
and a Normal likelihood for each observation
$$d_{\mathrm{obs},i} \sim \mathrm{Normal}(d_{\mathrm{true},i},\sigma_{d,i}^2) \; \; ∀ \; i ∈ 1... N_{\mathrm{obs}}$$
where
$$d_{\mathrm{true},i} = v_i / H_0.$$
It's often helpful to use vector notation, $\bf{d_{\mathrm{obs}}} \sim \mathrm{MvNormal}(\bf{d_{\mathrm{true}}},\bf{\sigma_{d}}^2).$
We implement this model using the following code
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-r'¿°persist_js_state·has_pluto_hook_features§cell_idÙ$4f11d0e2-7126-47f1-865a-3474298597dc¹depends_on_disabled_cells§runtimeÎ îÛµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$337a560b-49f3-4fc5-926f-1689911eacf2Цqueued¤logs�§running¦output†¤bodyÙÔQ2d: Can you think of another improvement we could make to improve the quality of inferences about the expansion rate of the universe? Explain your thinking.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-wÀ°persist_js_state·has_pluto_hook_features§cell_idÙ$337a560b-49f3-4fc5-926f-1689911eacf2¹depends_on_disabled_cells§runtimeΠ׳µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6Цqueued¤logs�§running¦output†¤bodyÚLOne nice feature of using a PPL like Turing is that they make it easy to repeat analyses using slightly different assumptions. For example, we could switch to using a LogNormal prior distribution for $H_0$ .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-s ´°persist_js_state·has_pluto_hook_features§cell_idÙ$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6¹depends_on_disabled_cells§runtimeΠ癵published_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d81347d3-9246-42d9-9a85-42c773ef2a1dЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ8‡?u°persist_js_state·has_pluto_hook_features§cell_idÙ$d81347d3-9246-42d9-9a85-42c773ef2a1d¹depends_on_disabled_cells§runtimeÎ
µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$adf117fe-0f54-4f2a-b107-0635f56263f2Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_2e²last_run_timestampËAÙæœ:B‡#°persist_js_state·has_pluto_hook_features§cell_idÙ$adf117fe-0f54-4f2a-b107-0635f56263f2¹depends_on_disabled_cells§runtimeÍ3³µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2ad2563a-8a72-47e8-a36d-f6d2a49cb517Цqueued¤logs�§running¦output†¤bodyƒ¨elements’’’§60.3487ªtext/plain’’¨0.219384ªtext/plain¤type¥Tuple¨objectid¯4b9a8caf7d8be94¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÙæœF6I^°persist_js_state·has_pluto_hook_features§cell_idÙ$2ad2563a-8a72-47e8-a36d-f6d2a49cb517¹depends_on_disabled_cells§runtimeÎ Qµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c086c05f-ad73-44c7-bf8b-a304d3533690Цqueued¤logs�§running¦output†¤bodyÚ
calc_sigma_mle_linear_model
calc_sigma_mle_linear_model(A, covar)
Computes the uncertainty in the maximum likelihood estimate of θ for the linear model y = A θ where measurements errors of y_obs are normally distributed and have covariance covar. Note that y_obs is not passed to this function, because it does not affect results.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœHïȰpersist_js_state·has_pluto_hook_features§cell_idÙ$c086c05f-ad73-44c7-bf8b-a304d3533690¹depends_on_disabled_cells§runtimeÎñaµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0a4aaa8a-20da-486f-ace5-fbadcf646609Цqueued¤logs�§running¦output†¤body…¦prefix¹MCMCChains.ChainDataFrame¨elements’’’ƒ¤rows‘’˜’¥:Hâ‚€ªtext/plain’§60.3487ªtext/plain’¨0.219384ªtext/plain’ª0.00439378ªtext/plain’§2483.64ªtext/plain’§3620.04ªtext/plain’§1.00149ªtext/plain’§140.644ªtext/plain¨objectid°c55628879e8dd746¦schema‚¥names˜ªparameters¤mean£std¤mcse¨ess_bulk¨ess_tail¤rhat«ess_per_sec¥types˜¦Symbol§Float64§Float64§Float64§Float64§Float64§Float64§Float64Ù"application/vnd.pluto.table+object’’ƒ¤rows‘’–’¥:Hâ‚€ªtext/plain’§59.9081ªtext/plain’§60.2037ªtext/plain’§60.3499ªtext/plain’§60.4926ªtext/plain’§60.7849ªtext/plain¨objectid°39812bcc41032804¦schema‚¥names–ªparameters¤2.5%¥25.0%¥50.0%¥75.0%¥97.5%¥types–¦Symbol§Float64§Float64§Float64§Float64§Float64Ù"application/vnd.pluto.table+object¤type¥Array¬prefix_short ¨objectid°c6c658ca930e6624¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÙæœF]Ù°persist_js_state·has_pluto_hook_features§cell_idÙ$0a4aaa8a-20da-486f-ace5-fbadcf646609¹depends_on_disabled_cells§runtimeÏ Hä´[µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$eb72dda6-69f0-4538-a75a-25967653759fЦqueued¤logs�§running¦output†¤bodyÙyNow we can compare the estimates of the posterior PDF under the two different models.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-s9X°persist_js_state·has_pluto_hook_features§cell_idÙ$eb72dda6-69f0-4538-a75a-25967653759f¹depends_on_disabled_cells§runtimeΠ脵published_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2d97268e-560b-4398-982e-1cf5cd9ab7ddЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ:?åÖ°persist_js_state·has_pluto_hook_features§cell_idÙ$2d97268e-560b-4398-982e-1cf5cd9ab7dd¹depends_on_disabled_cells§runtimeÍg¶µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$28b844a8-650a-47d8-b9f6-586f22d6f603Цqueued¤logs�§running¦output†¤bodyÚ)Hmm... This value is significantly different that what we found above. Why? In the calls above, we used the method of Ordinary Least Squares which ignores the measurement uncertainties and weights each point equally. We can instead request it use the method of Weighted Least Squares and tell it to use inverse variance weighting as shown below.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-p�ްpersist_js_state·has_pluto_hook_features§cell_idÙ$28b844a8-650a-47d8-b9f6-586f22d6f603¹depends_on_disabled_cells§runtimeÎ ÈÛµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c78f0ad9-03c0-4066-a390-193e7bfa84b1Цqueued¤logs�§running¦output†¤bodyÙæQ2e: How could using a probabilistic programming language like Turing make it relatively easy to improve the quality of our inferences about the expansion rate of our universe?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-wܰpersist_js_state·has_pluto_hook_features§cell_idÙ$c78f0ad9-03c0-4066-a390-193e7bfa84b1¹depends_on_disabled_cells§runtimeÎ ¡eµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1c35257a-9b98-4af6-bde0-a945665c91cdЦqueued¤logs�§running¦output†¤bodyÚo
Propagation of uncertainties
The data file provide measurement uncertainties for the distance modulus. We'd like measurement uncertainties for the distance. Unders several assumptions (e.g., small magnitude of uncertainties, uncorrelated uncertainties), we can estimate the measurement uncertainty in the distance by applying the Propagation of uncertainties method. If you haven't seen this before, then I'd suggest that you just trust me on this for now rather than worrying about the derivation of the equation used.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8�¬°°persist_js_state·has_pluto_hook_features§cell_idÙ$1c35257a-9b98-4af6-bde0-a945665c91cd¹depends_on_disabled_cells§runtimeÎ 8µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1i²last_run_timestampËAÙæœ95ð°persist_js_state·has_pluto_hook_features§cell_idÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6¹depends_on_disabled_cells§runtimeÍ0_µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7dbЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8šÎÿ°persist_js_state·has_pluto_hook_features§cell_idÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7db¹depends_on_disabled_cells§runtimeÎtÂ$µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$20f739ff-cc5b-460e-851a-141003d0c9d0Цqueued¤logs�§running¦output†¤bodyÙmNow the value returned should match our previous analysis very closely.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-p©ç°persist_js_state·has_pluto_hook_features§cell_idÙ$20f739ff-cc5b-460e-851a-141003d0c9d0¹depends_on_disabled_cells§runtimeÎ çµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$f76f4c3c-74f1-44b0-9b3a-5895aec22e70Цqueued¤logs�§running¦output†¤body²57.189921141742445¤mimeªtext/plain¬rootassignee«Hâ‚€_bf_all²last_run_timestampËAÙæœHlµ°persist_js_state·has_pluto_hook_features§cell_idÙ$f76f4c3c-74f1-44b0-9b3a-5895aec22e70¹depends_on_disabled_cells§runtimeÍ@kµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a98ace81-9afd-4618-88a6-fadaf04eb364Цqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8ω/°persist_js_state·has_pluto_hook_features§cell_idÙ$a98ace81-9afd-4618-88a6-fadaf04eb364¹depends_on_disabled_cells§runtimeÍ^ɵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1e²last_run_timestampËAÙæœ8Ð<Ú°persist_js_state·has_pluto_hook_features§cell_idÙ$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1¹depends_on_disabled_cells§runtimeÍ-¬µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$95bc4b33-d619-4a95-af19-5771d209336dЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ6ê¼°persist_js_state·has_pluto_hook_features§cell_idÙ$95bc4b33-d619-4a95-af19-5771d209336d¹depends_on_disabled_cells§runtimeÍ»0µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0Цqueued¤logs�§running¦output†¤bodyÙºPlot the data
It's often a good idea to make a quick plot to help validate our dataset and to understand the characteristics of the data.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-]·V°persist_js_state·has_pluto_hook_features§cell_idÙ$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0¹depends_on_disabled_cells§runtimeÎ K>µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2532e9de-8fa7-44ce-8502-c2473928aa8eЦqueued¤logs�§running¦output†¤bodyÚ6
Full Width Mode
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ:Jös°persist_js_state·has_pluto_hook_features§cell_idÙ$2532e9de-8fa7-44ce-8502-c2473928aa8e¹depends_on_disabled_cells§runtimeÎ N:µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4a2c109d-8e18-4561-913b-769f7eaeb6e9Цqueued¤logs�§running¦output†¤bodyÚ
¾Develop a model
In this case, it may be tempting to rush to fitting a line to the data. But we want to use this example as a chance to think through the process of building models. It's often useful to divide the full model for astronomical observations into two parts: a physical model and a measurement model.
Physical model
In this case, our initial physical model is that the local universe is expanding away from us at a velocity ($v$ ) proportion to the distance ($d$ ). The rate of proportionality is known as the Hubble constant ($H_0$ ). If this model were perfectly accurate and there were no measurement errors, then we'd have $d = H_0^{-1} v.$
Measurement model
Astronomical measurements almost always have some measurement errors. It can be useful to be explicit about when we're referring to the true value and when we're referring to the observed value. For example, if we were measuring $v$ , then we might write: $d_{\rm obs} = d_{\rm true} + \epsilon,$ where $\epsilon$ is the measurement error. By definition the true value of the measurement error ($\epsilon$ ) is almost always unknown.
Typically, astronomers design the measurements such that the expected value of the measurement is equal the true value ($E[d_{\rm obs}] = d_{\rm true}$ ), and characterize the distribution of the measurement errors. One very common model/approximation is that the measurement errors follow a Normal (or Gaussian) distribution with a scale parameter, $\sigma$ . We denote that with
$$\epsilon \sim \mathrm{Normal}(0,\sigma^2).$$
Based on the properties of the Normal distribution, $E[\epsilon]=0$ , and $E[\epsilon^2] = \sigma^2$ . For this lab, we'll assume that's a good approximation here.
When we have many measurements, we could write the errors explicitly like $d_{i,\rm obs} = d_{i,\rm true} + \epsilon_i = v_i/H_0 + \epsilon_i,$ where $\epsilon_i \sim \mathrm{Normal}(0,\sigma_i^2)$ for each obsevation $i\in 1...N_{\mathrm obs}$
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-lº^°persist_js_state·has_pluto_hook_features§cell_idÙ$4a2c109d-8e18-4561-913b-769f7eaeb6e9¹depends_on_disabled_cells§runtimeÎ =Ê¡µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2f3d492c-4a5e-4a56-a773-e8078e14476aЦqueued¤logs�§running¦output†¤body…¦prefix§Float64¨elements‘’’©0.0174856ªtext/plain¤type¥Array¬prefix_short ¨objectid°f6933da58ca8811b¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee®Hâ‚€inv_bf_all²last_run_timestampËAÙæœH°–°persist_js_state·has_pluto_hook_features§cell_idÙ$2f3d492c-4a5e-4a56-a773-e8078e14476a¹depends_on_disabled_cells§runtimeÎFOj¾µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c43f2686-da2d-4b67-b87e-7c22bd09257cЦqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1g²last_run_timestampËAÙæœ9 ðJ°persist_js_state·has_pluto_hook_features§cell_idÙ$c43f2686-da2d-4b67-b87e-7c22bd09257c¹depends_on_disabled_cells§runtimeÍ;�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b54f8319-dce6-4009-873e-bd47dc2a4619Цqueued¤logs�§running¦output†¤bodyÉ á]
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœH˜!°persist_js_state·has_pluto_hook_features§cell_idÙ$b54f8319-dce6-4009-873e-bd47dc2a4619¹depends_on_disabled_cells§runtimeÎ Aˆ“µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7Цqueued¤logs�§running¦output†¤bodyÙnQ1g: How precise is our estimate of the Hubble constant?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-q,‘°persist_js_state·has_pluto_hook_features§cell_idÙ$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7¹depends_on_disabled_cells§runtimeÎ |^µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a6cf5e52-8692-4e3c-95aa-11167b118bd4Цqueued¤logs�§running¦output†¤bodyÚ Evaluating the posterior PDF direclty is hard (often due to the noramlization constant). To get around the challenge, Turing allows us to generate samples from the posterior PDF. There are many interesting algorithms for sampling from a complex posterior distribution. Here, we'll adopt the "NUTS" sampler which based on Hamiltonian Monte Carlo . The algorithm is quite complex, so we won't go into the details. But it's good to konw that this is often a good choice for models with a few to dozens of model parameters. We'll specify that we want it to draw num_mcmc_samples samples and repeat the calculation num_chains different times (running in parallel).
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-r–«°persist_js_state·has_pluto_hook_features§cell_idÙ$a6cf5e52-8692-4e3c-95aa-11167b118bd4¹depends_on_disabled_cells§runtimeÎ |µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179dЦqueued¤logs�§running¦output†¤bodyÙb
Visualize $\chi^2$ or Loss Function
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-m*™°persist_js_state·has_pluto_hook_features§cell_idÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179d¹depends_on_disabled_cells§runtimeÎ æ@µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0991f15c-b734-480b-8b12-6d2beda547dbЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ=ÚëѰpersist_js_state·has_pluto_hook_features§cell_idÙ$0991f15c-b734-480b-8b12-6d2beda547db¹depends_on_disabled_cells§runtimeÎ „µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$5c9b0395-4d2e-4679-8d86-b9581fa0f66cЦqueued¤logs�§running¦output†¤bodyÙ‚
Fitting a Model to Data
Computing Maximum Likelihood Estimator for model parameters
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-m™_°persist_js_state·has_pluto_hook_features§cell_idÙ$5c9b0395-4d2e-4679-8d86-b9581fa0f66c¹depends_on_disabled_cells§runtimeÎ `•µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$340dc0ff-dd1c-44e0-907c-f357adb122d5Цqueued¤logs�§running¦output†¤body…¦prefixÙ·DynamicPPL.Model{typeof(model_hubble_law_uniform_prior), (:v, :d_obs, :σ_d_obs), (), (), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}}, Tuple{}, DynamicPPL.DefaultContext}¨elements”’¡f’Ù@model_hubble_law_uniform_prior (generic function with 2 methods)ªtext/plain’¤args’ƒ¨elements“’¡v’…¦prefix§Float64¨elements—’’§8418.88ªtext/plain’’§14627.6ªtext/plain’’§15447.5ªtext/plain’’§20276.6ªtext/plain’’§18199.8ªtext/plain¤more’Í€’§57893.3ªtext/plain¤type¥Array¬prefix_short ¨objectid°cfe55747b0413d3eÙ!application/vnd.pluto.tree+object’¥d_obs’…¦prefix§Float64¨elements—’’§117.305ªtext/plain’’§217.007ªtext/plain’’§230.961ªtext/plain’’§308.565ªtext/plain’’§313.821ªtext/plain¤more’Í€’§1291.84ªtext/plain¤type¥Array¬prefix_short ¨objectid°14301e3138d6cedcÙ!application/vnd.pluto.tree+object’¨Ïƒ_d_obs’…¦prefix§Float64¨elements—’’§12.0956ªtext/plain’’§16.6721ªtext/plain’’§16.5664ªtext/plain’’§22.5181ªtext/plain’’§22.5595ªtext/plain¤more’Í€’§145.219ªtext/plain¤type¥Array¬prefix_short ¨objectid°6af18a9b6659a5c3Ù!application/vnd.pluto.tree+object¤typeªNamedTuple¨objectid°59d0421f6398110fÙ!application/vnd.pluto.tree+object’¨defaults’ƒ¨elements�¤typeªNamedTuple¨objectid°ffffffff412bd36eÙ!application/vnd.pluto.tree+object’§context’…¦prefix¹DynamicPPL.DefaultContext¨elements�¤type¦struct¬prefix_short®DefaultContext¨objectid°ffffffff9dc0ec1dÙ!application/vnd.pluto.tree+object¤type¦struct¬prefix_short¥Model¨objectid°c67d7cae117a1fc3¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÙ)model_hubble_law_uniform_prior_given_data²last_run_timestampËAÙæœ>
C‘°persist_js_state·has_pluto_hook_features§cell_idÙ$340dc0ff-dd1c-44e0-907c-f357adb122d5¹depends_on_disabled_cells§runtimeÎVi®µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0c25a4cc-9f53-4729-985b-de692278c433Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1d²last_run_timestampËAÙæœ8Ï ¨°persist_js_state·has_pluto_hook_features§cell_idÙ$0c25a4cc-9f53-4729-985b-de692278c433¹depends_on_disabled_cells§runtimeÍ/dµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ad758d43-b135-418e-a29c-36cea3a24457Цqueued¤logs�§running¦output†¤bodyÚ
Tip
MvNormal specifies a multivariate normal distribution with one output for each observation. The expected value for each observation is $d_\mathrm{true}$ and the standard deviation of each measurement is given by $\sigma_{d,\mathrm{obs}}$ . In principle, we could pass a covariance matrix for the second argument to describe correlated measurement uncertainties. Instead, we've provided a vector for the second arguement, asking for a model that assume uncorrelated measurement errors.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9
°persist_js_state·has_pluto_hook_features§cell_idÙ$ad758d43-b135-418e-a29c-36cea3a24457¹depends_on_disabled_cells§runtimeÎ À¦¶µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$18edb530-8472-4932-946c-917d8ab9dbdeЦqueued¤logs�§running¦output†¤body…¦prefix¹MCMCChains.ChainDataFrame¨elements’’’ƒ¤rows‘’˜’¥:Hâ‚€ªtext/plain’§60.3384ªtext/plain’¨0.218416ªtext/plain’ª0.00426102ªtext/plain’§2637.15ªtext/plain’§4056.84ªtext/plain’§1.00055ªtext/plain’§492.281ªtext/plain¨objectid°520a169c4f6f55b6¦schema‚¥names˜ªparameters¤mean£std¤mcse¨ess_bulk¨ess_tail¤rhat«ess_per_sec¥types˜¦Symbol§Float64§Float64§Float64§Float64§Float64§Float64§Float64Ù"application/vnd.pluto.table+object’’ƒ¤rows‘’–’¥:Hâ‚€ªtext/plain’§59.9109ªtext/plain’§60.1918ªtext/plain’§60.3403ªtext/plain’§60.4869ªtext/plain’¦60.762ªtext/plain¨objectid°2163b9cca998b5f1¦schema‚¥names–ªparameters¤2.5%¥25.0%¥50.0%¥75.0%¥97.5%¥types–¦Symbol§Float64§Float64§Float64§Float64§Float64Ù"application/vnd.pluto.table+object¤type¥Array¬prefix_short ¨objectid°aa7b4bd10492f4ad¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÙæœG†]%°persist_js_state·has_pluto_hook_features§cell_idÙ$18edb530-8472-4932-946c-917d8ab9dbde¹depends_on_disabled_cells§runtimeÎ 2t µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2b3729fc-62b2-478d-b35c-e69e6b0efc93Цqueued¤logs�§running¦output†¤bodyÚt
plot_hubble_diagram
plot_hubble_diagram(df, Hâ‚€; show_yerr, show_resid)
Plots distance versus velocity. Adds a line based on linear model of Hubble expansion with rate Hâ‚€. Optionally, plots residuals to model.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœHtÿÖ°persist_js_state·has_pluto_hook_features§cell_idÙ$2b3729fc-62b2-478d-b35c-e69e6b0efc93¹depends_on_disabled_cells§runtimeÎ ksôµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$92af3764-6c53-4e03-a338-81b1de202a04Цqueued¤logs�§running¦output†¤bodyÙF
Computing MLE via Linear Algebra
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-mÏ_°persist_js_state·has_pluto_hook_features§cell_idÙ$92af3764-6c53-4e03-a338-81b1de202a04¹depends_on_disabled_cells§runtimeÎ <µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0a998eb0-4bf5-4d4e-b193-54964b54f1abЦqueued¤logs�§running¦output†¤bodyÚ`One disadvantage of using simple text files to share data is that they don't have a uniform way to store metadata about the file. For example, it would be nice to include a longer description of the of each column. So after we've read in the datafile, we can add that metadata ourselves.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-\|p°persist_js_state·has_pluto_hook_features§cell_idÙ$0a998eb0-4bf5-4d4e-b193-54964b54f1ab¹depends_on_disabled_cells§runtimeÎ à]µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$8ab41174-d7d9-42c7-8129-381c54906280Цqueued¤logs�§running¦output†¤bodyÚ]Thinking a little more broadly, sometimes the goodness-of-fit statistic that we want to minimize is more complicated. So often people refer to minimizing an objective function or a loss function . We'll implement a $\chi^2$ loss function below.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-mH»°persist_js_state·has_pluto_hook_features§cell_idÙ$8ab41174-d7d9-42c7-8129-381c54906280¹depends_on_disabled_cells§runtimeÎ jèµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7f61c098-1c54-4c82-be40-f9fd154156a1Цqueued¤logs�§running¦output†¤bodyÚ
Choice of Priors
The choice of prior probability distributions is often subjective. For example, one astronomer might say that they want to assume as little as practical about the Hubble constant. This has some philosophical appeal, but it can be tricky to put into practice. For example, should we assume that the Hubble constant is positive? Should we assume that there's some maximum velocity (maybe the speed of light)? Should we assume that very large Hubble constants are less likely that small values? If so, what counts as "large"?
Another astronomer might take a different approach and want to approximation to our prior knowledge about the value of the Hubble constant based on previous studies (critically, excluding the data that is currently being analyzing). This also comes with follow-up questions. Should we approximate our prior knowledge with a simple, named distribution? Or should we use a more complex prior to better describe the conclusions of previous research?
There are almost always some very bad choices for priors. But often there's not a single best choice. Rather than trying to find "the correct" prior, it's often wise to perform multiple analyses with multiple reasonable choices for priors. You may find the the difference in outcome are so small that they don't affect your conclusions. Or you might discover than even small differences in the choice of the priors can have a substantive impact on the conclusions. Knowing which regime you're in is often more a valuable result than computing the result under one single choice of priors.
Here, if we assumed a broad uniform prior for $H_0$ , then the maximum a posteriori estimate (MAP) would match the MLE. Altneratively, we might adopt as Log-Normal distribution , since it has non-zero probability for all positive values and we're able to pick a location for the peak and scale that are qualitatively similar to what we had already learned from previous studies.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9ñ°persist_js_state·has_pluto_hook_features§cell_idÙ$7f61c098-1c54-4c82-be40-f9fd154156a1¹depends_on_disabled_cells§runtimeÎ —¨µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ef78506f-0326-4bd0-8fb3-af6f34a06841Цqueued¤logs�§running¦output†¤bodyÚÁ
Tip
To type unicode characters like σ, first type \, then the name of the character your want (e.g., 'sigma'), then press tab. For the subscript ₜ, you'd type \_t+TAB.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8z†Ë°persist_js_state·has_pluto_hook_features§cell_idÙ$ef78506f-0326-4bd0-8fb3-af6f34a06841¹depends_on_disabled_cells§runtimeÎÝ';µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$316f65a1-9062-4cb0-a3fb-af54149afb4dЦqueued¤logs�§running¦output†¤bodyÉ L$
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœH�¨"°persist_js_state·has_pluto_hook_features§cell_idÙ$316f65a1-9062-4cb0-a3fb-af54149afb4d¹depends_on_disabled_cells§runtimeÎ˵published_object_keys�¸depends_on_skipped_cells§erroredÂÙ$8ddbc921-4541-4c45-90c5-5c51ec2e391aЦqueued¤logs�§running¦output†¤bodyÚ“StatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Vector{Float64}}, GLM.DensePredChol{Float64, CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}}}, Matrix{Float64}}
dâ‚— ~ 0 + v
Coefficients:
────────────────────────────────────────────────────────────────
Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
────────────────────────────────────────────────────────────────
v 0.0312674 0.000388205 80.54 <1e-99 0.030505 0.0320299
────────────────────────────────────────────────────────────────¤mimeªtext/plain¬rootassignee§ols_all²last_run_timestampËAÙæœ={g°persist_js_state·has_pluto_hook_features§cell_idÙ$8ddbc921-4541-4c45-90c5-5c51ec2e391a¹depends_on_disabled_cells§runtimeÎ<óÔzµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d67f0b9e-10be-4511-93ab-edceb3aef49cЦqueued¤logs�§running¦output†¤body±57.18992114174244¤mimeªtext/plain¬rootassignee¬Hâ‚€_wls_all²last_run_timestampËAÙæœ=Ç¢U°persist_js_state·has_pluto_hook_features§cell_idÙ$d67f0b9e-10be-4511-93ab-edceb3aef49c¹depends_on_disabled_cells§runtimeÍE;µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1eb1face-a795-4cb3-9c51-f995f73e2509Цqueued¤logs�§running¦output†¤bodyÉ X.
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœC[�°persist_js_state·has_pluto_hook_features§cell_idÙ$1eb1face-a795-4cb3-9c51-f995f73e2509¹depends_on_disabled_cells§runtimeÎ�a¶µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ccdf5418-12e4-49ee-bdea-90efc202583aЦqueued¤logs�§running¦output†¤body²0.2256856880537995¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœHtZİpersist_js_state·has_pluto_hook_features§cell_idÙ$ccdf5418-12e4-49ee-bdea-90efc202583a¹depends_on_disabled_cells§runtimeÎ ŸOµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2efb7fb2-0402-4eec-b58a-a52fd530e3f5Цqueued¤logs�§running¦output†¤bodyÙ8
Read the Data file
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-[vâ°persist_js_state·has_pluto_hook_features§cell_idÙ$2efb7fb2-0402-4eec-b58a-a52fd530e3f5¹depends_on_disabled_cells§runtimeÎ N'µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3a06141a-a92d-4c31-9950-13f0bf2c023aЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9
œ$°persist_js_state·has_pluto_hook_features§cell_idÙ$3a06141a-a92d-4c31-9950-13f0bf2c023a¹depends_on_disabled_cells§runtimeÍl‡µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$bf7ca6ea-4c07-46e4-baff-b205e1663505Цqueued¤logs�§running¦output†¤bodyÙe
Astro 416: Lab 3, Ex 1
Model Building I: Linear Models
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ6¾éd°persist_js_state·has_pluto_hook_features§cell_idÙ$bf7ca6ea-4c07-46e4-baff-b205e1663505¹depends_on_disabled_cells§runtimeÎ z‰µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2656d886-60dc-44a7-b318-100335dcf05bЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ9 J¾°persist_js_state·has_pluto_hook_features§cell_idÙ$2656d886-60dc-44a7-b318-100335dcf05b¹depends_on_disabled_cells§runtimeÎ ·šµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2c1c7d8a-eda6-4900-9be7-e4b908fed81aЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ:M’)°persist_js_state·has_pluto_hook_features§cell_idÙ$2c1c7d8a-eda6-4900-9be7-e4b908fed81a¹depends_on_disabled_cells§runtimeÍXKµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861Цqueued¤logs�§running¦output†¤bodyÚ/
predict_linear_model
predict_linear_model(A, θ)
Computes the predictions of a linear model with design matrix A and parameters θ.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœG´6—°persist_js_state·has_pluto_hook_features§cell_idÙ$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861¹depends_on_disabled_cells§runtimeÎ �sµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9ef67704-5063-4f75-853b-078261e50684Цqueued¤logs�§running¦output†¤bodyÙÇNow we'll call a function (implemented at the bottom of the notebook) to compute the best-fit model parameters for a linear model using linear algebra.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-nY°persist_js_state·has_pluto_hook_features§cell_idÙ$9ef67704-5063-4f75-853b-078261e50684¹depends_on_disabled_cells§runtimeÎ ÷�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$095bdd00-ffa9-434d-9fc5-0978019b060bЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ-k x°persist_js_state·has_pluto_hook_features§cell_idÙ$095bdd00-ffa9-434d-9fc5-0978019b060b¹depends_on_disabled_cells§runtimeÍ!bµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ71»¥°persist_js_state·has_pluto_hook_features§cell_idÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21¹depends_on_disabled_cells§runtimeÎ,¦!-µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1c²last_run_timestampËAÙæœ8œc°persist_js_state·has_pluto_hook_features§cell_idÙ$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3¹depends_on_disabled_cells§runtimeÍ.`µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ac1a64e8-7a5c-43b5-923a-633dac4fb664Цqueued¤logs�§running¦output†¤bodyÚ’A vector containing each distance measurement, $y_{\mathrm{obs}} = \left( \begin{matrix} d_{\mathrm{obs},1} \\ d_{\mathrm{obs},1} \\ \ddots \\ d_{\mathrm{obs},N_{\mathrm{obs}}} \\ \end{matrix} \right),$
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-n
°persist_js_state·has_pluto_hook_features§cell_idÙ$ac1a64e8-7a5c-43b5-923a-633dac4fb664¹depends_on_disabled_cells§runtimeÎ 0œµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d9058d92-b1c9-44f2-af5c-3540932dec48Цqueued¤logs�§running¦output†¤bodyÚ(580×1 Matrix{Float64}:
8418.88481647824
14627.575677119486
15447.48986863275
20276.642884103174
18199.795349043794
25112.584489113477
22633.922447377583
â‹®
196189.6799380773
181491.20959052688
205506.61090385227
160872.3420882188
198275.00548168243
134805.21731591862¤mimeªtext/plain¬rootassignee¥A_all²last_run_timestampËAÙæœ:ÉL˜°persist_js_state·has_pluto_hook_features§cell_idÙ$d9058d92-b1c9-44f2-af5c-3540932dec48¹depends_on_disabled_cells§runtimeÎ ‚Ý�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0e42628b-95a9-45a0-b375-51f62dc0ce0dЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8œñ°persist_js_state·has_pluto_hook_features§cell_idÙ$0e42628b-95a9-45a0-b375-51f62dc0ce0d¹depends_on_disabled_cells§runtimeÍX|µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœ6á°persist_js_state·has_pluto_hook_features§cell_idÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8¹depends_on_disabled_cells§runtimeÎ_ìŵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a2b56e1c-9735-49b0-91da-40f489823390Цqueued¤logs�§running¦output†¤bodyÚ2
Tip
We could have created the matrix with the diagm function. Instead, we used PDiagMat to create a matrix that the computer knows will always be diagonal and positive definite. This allows it to use algorithms that are faster and/or more robust than if it couldn't assume anything about the propeties of the covariance matrix.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ8ϸ�°persist_js_state·has_pluto_hook_features§cell_idÙ$a2b56e1c-9735-49b0-91da-40f489823390¹depends_on_disabled_cells§runtimeÎ òfµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348Цqueued¤logs�§running¦output†¤bodyÙéQ1f: What velocity threshold did you pick? What is the results best-fit Hubble constant? How does this compare to the best-fit Hubble constant when fitting to the full data set?
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-qZ°persist_js_state·has_pluto_hook_features§cell_idÙ$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348¹depends_on_disabled_cells§runtimeÎ Ž�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$e4ca4972-42c8-4426-94ae-e316662513c3Цqueued¤logs�§running¦output†¤bodyÙZ
Computing MLE with package for General Linear Models
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-nªe°persist_js_state·has_pluto_hook_features§cell_idÙ$e4ca4972-42c8-4426-94ae-e316662513c3¹depends_on_disabled_cells§runtimeÎ ,aµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$6a75dd68-5034-4b16-89a0-7388cfae0cbdЦqueued¤logs�§running¦output†¤bodyÙeWe'll package the velocities and uncertainties into matrices.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-n@°persist_js_state·has_pluto_hook_features§cell_idÙ$6a75dd68-5034-4b16-89a0-7388cfae0cbd¹depends_on_disabled_cells§runtimeÎ ÖRµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d68dd4b4-c091-4435-a286-3de589b19009Цqueued¤logs�§running¦output†¤bodyÚAFor a linear model, we can estimate the measurement uncertainty associated with our maximum likelihood estimators. It's most intuitive to plot the $\Delta\chi^2$ as a function of $H_0$ . By construction, the slope of $\chi^2(H_0)$ is zero at the best-fit value. The magnitude of the measurement uncertainty is inversely proportional to the curvature (absolute value of the second derivative) of $\chi^2(H_0)$ .
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-q_¢°persist_js_state·has_pluto_hook_features§cell_idÙ$d68dd4b4-c091-4435-a286-3de589b19009¹depends_on_disabled_cells§runtimeÎ |õµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$33045766-a7c5-42ff-bdf8-bde1fce9c56bЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ9'>B°persist_js_state·has_pluto_hook_features§cell_idÙ$33045766-a7c5-42ff-bdf8-bde1fce9c56b¹depends_on_disabled_cells§runtimeÍeýµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9555ae09-be3d-48e8-9ee2-face2bef8cceЦqueued¤logs�§running¦output†¤bodyÙN
Fitting model to a subset of the dataset
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-pà °persist_js_state·has_pluto_hook_features§cell_idÙ$9555ae09-be3d-48e8-9ee2-face2bef8cce¹depends_on_disabled_cells§runtimeΠܵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$466dacda-1835-42fd-b8f4-cac5c22f6756Цqueued¤logs�§running¦output†¤bodyÚÁStatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Vector{Float64}}, GLM.DensePredChol{Float64, CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}}}, Matrix{Float64}}
dâ‚— ~ 1 + v
Coefficients:
────────────────────────────────────────────────────────────────────────────────────
Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
────────────────────────────────────────────────────────────────────────────────────
(Intercept) -670.283 56.9651 -11.77 <1e-28 -782.167 -558.399
v 0.0367312 0.000580867 63.24 <1e-99 0.0355903 0.037872
────────────────────────────────────────────────────────────────────────────────────¤mimeªtext/plain¬rootassignee¨ols_try1²last_run_timestampËAÙæœ=^/o°persist_js_state·has_pluto_hook_features§cell_idÙ$466dacda-1835-42fd-b8f4-cac5c22f6756¹depends_on_disabled_cells§runtimeνT«5µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64daЦqueued¤logs�§running¦output†¤bodyÉ ½ì
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœG¦Å
°persist_js_state·has_pluto_hook_features§cell_idÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64da¹depends_on_disabled_cells§runtimeÎI“µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$fb2545e1-d624-4669-9e07-c94a598ba8edЦqueued¤logs�§running¦output†¤bodyÙªMissing Response
Replace missing with your answer.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ:@é°persist_js_state·has_pluto_hook_features§cell_idÙ$fb2545e1-d624-4669-9e07-c94a598ba8ed¹depends_on_disabled_cells§runtimeÍ[“µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04aЦqueued¤logs�§running¦output†¤body²0.1942240396774738¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÙæœH‰r°persist_js_state·has_pluto_hook_features§cell_idÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04a¹depends_on_disabled_cells§runtimeÎ n‹µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$389e8239-6f62-46fb-8b13-d336516e5e2fЦqueued¤logs�§running¦output†¤bodyÈéi
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœ:3C°persist_js_state·has_pluto_hook_features§cell_idÙ$389e8239-6f62-46fb-8b13-d336516e5e2f¹depends_on_disabled_cells§runtimeÎXäÈœµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$54b51239-59b0-4767-9bc8-018d77ee5e44Цqueued¤logs�§running¦output†¤bodyÚ#We can plot histograms for each of the calculations. We can compute an estimtae of the posterior density ($p(H_0|\bf{v},\bf{d},\bf{\sigma_d})$ ) using the samples from each chain.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-r°°persist_js_state·has_pluto_hook_features§cell_idÙ$54b51239-59b0-4767-9bc8-018d77ee5e44¹depends_on_disabled_cells§runtimeÎ M̵published_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617Цqueued¤logs�§running¦output†¤bodyÚOr we can use an analytic expression for the uncertainty for parameters estimated from a general linear model,
$$E\left[\mathrm{Covar}(\theta)\right] = (A' \Sigma^{-1} A)^{-1}$$
and propagate the uncertainties for $H_0$ . We'll skip the tedious derivation, but you can see the implementation in the function calc_sigma_mle_linear_model at the bottom of this notebook.
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-q•>°persist_js_state·has_pluto_hook_features§cell_idÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617¹depends_on_disabled_cells§runtimeÎ û�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$aab05339-dea2-4c7f-8b38-bc7d7971f1d9Цqueued¤logs�§running¦output†¤bodyÙ4
Functions used
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÙæœ-x°persist_js_state·has_pluto_hook_features§cell_idÙ$aab05339-dea2-4c7f-8b38-bc7d7971f1d9¹depends_on_disabled_cells§runtimeÎ Í¿µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$46eb1088-0265-46a6-91ec-44dfa3bd862dЦqueued¤logs�§running¦output†¤bodyÉ ¼
¤mimeimage/svg+xml¬rootassigneeÀ²last_run_timestampËAÙæœ:ƒ½¥°persist_js_state·has_pluto_hook_features§cell_idÙ$46eb1088-0265-46a6-91ec-44dfa3bd862d¹depends_on_disabled_cells§runtimeÎØ0µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$25ef65bd-8b86-4f88-b0b7-32f05ce82adaЦqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«response_1a²last_run_timestampËAÙæœ8—Šƒ°persist_js_state·has_pluto_hook_features§cell_idÙ$25ef65bd-8b86-4f88-b0b7-32f05ce82ada¹depends_on_disabled_cells§runtimeÍ+Ôµpublished_object_keys�¸depends_on_skipped_cells§errored±cell_dependenciesÞ ¡Ù$daa349a6-545b-4dfc-a3b0-92884da98e5e„´precedence_heuristic §cell_idÙ$daa349a6-545b-4dfc-a3b0-92884da98e5e´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$556d8f17-8a03-42c8-82c7-52c8125b604d„´precedence_heuristic §cell_idÙ$556d8f17-8a03-42c8-82c7-52c8125b604d´downstream_cells_map�µcalc_mle_linear_model’Ù$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8²upstream_cells_mapÞ ¤@doc�¨Docs.doc�®AbstractVector�®AbstractMatrix�§@assert�ªBase.throw�¤Docs�º#___this_pluto_module_name�¤size�§adjoint�¨PDiagMat�¦length�¤Base�¥PDMat�¡\�¢>=�¡*�¥Union�¢==�¤conj�³Base.AssertionError�Ù$77b17593-6a28-4294-9b17-41303d57d5a9„´precedence_heuristic §cell_idÙ$77b17593-6a28-4294-9b17-41303d57d5a9´downstream_cells_map�¤loss”Ù$0d0917aa-674e-47c4-a8dc-4d1585ebb70eÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04aÙ$ccdf5418-12e4-49ee-bdea-90efc202583a²upstream_cells_map†±AbstractDataFrame�£sum�¤abs2�¡-�¡/�¤Real�Ù$2482544e-ad05-495c-9787-0797939445be„´precedence_heuristic §cell_idÙ$2482544e-ad05-495c-9787-0797939445be´downstream_cells_map�©max_v_plt’Ù$0991f15c-b734-480b-8b12-6d2beda547dbÙ$b54f8319-dce6-4009-873e-bd47dc2a4619²upstream_cells_mapÞ §@md_str�§minimum�®PlutoUI.Slider�¡:�£max�¤Core�§PlutoUI‘Ù$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9¦isless�¨Base.get�¥@bind�¤ceil�¤Base�«PlutoRunner�·PlutoRunner.create_bond�¡/�¯Core.applicable�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¡*�§maximum�¨getindex�Ù$cd4fc36e-74f1-4b33-b92c-f0b7913a7203„´precedence_heuristic §cell_idÙ$cd4fc36e-74f1-4b33-b92c-f0b7913a7203´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$0735d5d6-9328-47f7-a764-24b4b8d92ca3„´precedence_heuristic §cell_idÙ$0735d5d6-9328-47f7-a764-24b4b8d92ca3´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$beeeb261-4dcb-4093-b1cd-08682785eade„´precedence_heuristic §cell_idÙ$beeeb261-4dcb-4093-b1cd-08682785eade´downstream_cells_map€²upstream_cells_map„§@md_str�¥aside�£tip�¨getindex�Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9„´precedence_heuristic §cell_idÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9´downstream_cells_map�¦df_allžÙ$46eb1088-0265-46a6-91ec-44dfa3bd862dÙ$316f65a1-9062-4cb0-a3fb-af54149afb4dÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70eÙ$d9058d92-b1c9-44f2-af5c-3540932dec48Ù$fa745b36-7465-443e-9f50-c786fe418c6aÙ$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bcÙ$466dacda-1835-42fd-b8f4-cac5c22f6756Ù$8ddbc921-4541-4c45-90c5-5c51ec2e391aÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82Ù$0991f15c-b734-480b-8b12-6d2beda547dbÙ$2482544e-ad05-495c-9787-0797939445beÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04a²upstream_cells_mapŒ¦select�¨@__dot__�¬colmetadata!�¡-�£log�²speed_of_light_mps‘Ù$a7d8f517-4117-4585-8089-117510c944c5¡/�¡^�¡+�¥df_in‘Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5®added_metadata‘Ù$d81347d3-9246-42d9-9a85-42c773ef2a1d¡*�Ù$d19e7f11-d1ff-4624-8603-38ffec0c7bea„´precedence_heuristic §cell_idÙ$d19e7f11-d1ff-4624-8603-38ffec0c7bea´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$c6f03d5d-18e2-4491-90fe-fe0008f774c4„´precedence_heuristic §cell_idÙ$c6f03d5d-18e2-4491-90fe-fe0008f774c4´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$629dae3a-46ec-40dc-b9ed-92de9eb21adb„´precedence_heuristic §cell_idÙ$629dae3a-46ec-40dc-b9ed-92de9eb21adb´downstream_cells_map€²upstream_cells_mapƒ«response_1e‘Ù$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1©ismissing�still_missing�Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5„´precedence_heuristic §cell_idÙ$4518f1f7-a2a3-4783-86ae-4413fc4291b5´downstream_cells_map�¥df_in’Ù$d81347d3-9246-42d9-9a85-42c773ef2a1dÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9²upstream_cells_map„£CSV‘Ù$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9¨filename‘Ù$3f2ef930-d367-11ef-3b5c-95b4989c2e21©DataFrame�¨CSV.read�Ù$e4597b96-6e06-44c2-a845-3d9967d2423c„´precedence_heuristic §cell_idÙ$e4597b96-6e06-44c2-a845-3d9967d2423c´downstream_cells_map€²upstream_cells_mapƒ©ismissing�«response_1i‘Ù$751eff6b-2ed2-4073-b8b5-02ad9981edb6still_missing�Ù$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8„´precedence_heuristic §cell_idÙ$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$6c86d0f1-5c6f-4204-9414-60577164f4b8„´precedence_heuristic §cell_idÙ$6c86d0f1-5c6f-4204-9414-60577164f4b8´downstream_cells_map�Ù+model_hubble_law_lognormal_prior_given_data‘Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3²upstream_cells_map‚¦df_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547dbÙ model_hubble_law_lognormal_prior‘Ù$d3db2bc4-a26b-4e01-a193-b155a92dab48Ù$a7981271-0b12-4b75-b5f0-5e91af761419„´precedence_heuristic §cell_idÙ$a7981271-0b12-4b75-b5f0-5e91af761419´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$276a850b-09da-41f0-8661-5d63bb2afdf8„´precedence_heuristic §cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8´downstream_cells_map�³chain_uniform_prior”Ù$1eb1face-a795-4cb3-9c51-f995f73e2509Ù$0a4aaa8a-20da-486f-ace5-fbadcf646609Ù$2ad2563a-8a72-47e8-a36d-f6d2a49cb517Ù$915fc532-7d8d-4ff5-81fd-af8f6e9e64da²upstream_cells_mapˆÙ)model_hubble_law_uniform_prior_given_data‘Ù$340dc0ff-dd1c-44e0-907c-f357adb122d5°num_mcmc_samples‘Ù$2c1c7d8a-eda6-4900-9be7-e4b908fed81a¤NUTS�ªnum_chains‘Ù$2c1c7d8a-eda6-4900-9be7-e4b908fed81a«MCMCThreads�¦sample�±ready_to_run_mcmc‘Ù$c433e938-31f7-4417-b3c0-a2f49fea8640§nothing�Ù$bd560d5d-3bc7-4b4d-aab7-67b1884a974b„´precedence_heuristic §cell_idÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974b´downstream_cells_map€²upstream_cells_map†§scatter�°loss_vs_Hâ‚€_all‘Ù$0d0917aa-674e-47c4-a8dc-4d1585ebb70e©Hâ‚€s_plt‘Ù$0d0917aa-674e-47c4-a8dc-4d1585ebb70e¥plot!�§xlabel!�§ylabel!�Ù$0236d055-0d6d-440d-a44b-0d5cb0ab2273„´precedence_heuristic §cell_idÙ$0236d055-0d6d-440d-a44b-0d5cb0ab2273´downstream_cells_map�«response_2b‘Ù$2d97268e-560b-4398-982e-1cf5cd9ab7dd²upstream_cells_map�§missing�Ù$efde0b1e-ec47-4180-aba7-ed8843395b50„´precedence_heuristic §cell_idÙ$efde0b1e-ec47-4180-aba7-ed8843395b50´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$48e246bc-4937-40d6-b686-73524f3ce057„´precedence_heuristic §cell_idÙ$48e246bc-4937-40d6-b686-73524f3ce057´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2786b37a-207f-4831-983e-81a380c37045„´precedence_heuristic §cell_idÙ$2786b37a-207f-4831-983e-81a380c37045´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$0d0917aa-674e-47c4-a8dc-4d1585ebb70e„´precedence_heuristic §cell_idÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70e´downstream_cells_map‚°loss_vs_Hâ‚€_all‘Ù$bd560d5d-3bc7-4b4d-aab7-67b1884a974b©Hâ‚€s_plt‘Ù$bd560d5d-3bc7-4b4d-aab7-67b1884a974b²upstream_cells_map„£map�¥range�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¤loss‘Ù$77b17593-6a28-4294-9b17-41303d57d5a9Ù$d3e82a29-c1b5-4f5a-ba96-a64d22636493„´precedence_heuristic §cell_idÙ$d3e82a29-c1b5-4f5a-ba96-a64d22636493´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$49090825-2843-4b3e-8ee6-658187232f96„´precedence_heuristic §cell_idÙ$49090825-2843-4b3e-8ee6-658187232f96´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$e0e610d7-a237-42ea-8706-8e09858fba03„´precedence_heuristic §cell_idÙ$e0e610d7-a237-42ea-8706-8e09858fba03´downstream_cells_map€²upstream_cells_mapƒ©ismissing�«response_2e‘Ù$adf117fe-0f54-4f2a-b107-0635f56263f2still_missing�Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0a„´precedence_heuristic §cell_idÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0a´downstream_cells_map€²upstream_cells_mapÞ «Hâ‚€_bf_all‘Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70¡!�«Ïƒ_Hâ‚€_fit‘Ù$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8¦df_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547db£map�¥range�¥plot!�¤fill�¨scatter!�«response_1f‘Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88¬Hâ‚€_wls_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547db¤size�«Ïƒ_Hâ‚€_all‘Ù$1d70572f-214e-4161-b804-2c3b7c077c56©ismissing�¤loss‘Ù$77b17593-6a28-4294-9b17-41303d57d5a9¡-�¦ylims!�¤plot�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¡+�¡*�¬Hâ‚€_wls_all‘Ù$d67f0b9e-10be-4511-93ab-edceb3aef49cÙ$1d70572f-214e-4161-b804-2c3b7c077c56„´precedence_heuristic §cell_idÙ$1d70572f-214e-4161-b804-2c3b7c077c56´downstream_cells_map‚®Ïƒ_Hâ‚€inv_all�«Ïƒ_Hâ‚€_all‘Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0a²upstream_cells_mapˆ«Hâ‚€_bf_all‘Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70¡/�¦Î£_all‘Ù$fa745b36-7465-443e-9f50-c786fe418c6a»calc_sigma_mle_linear_model‘Ù$c086c05f-ad73-44c7-bf8b-a304d3533690¥A_all‘Ù$d9058d92-b1c9-44f2-af5c-3540932dec48¡*�®Hâ‚€inv_bf_all‘Ù$2f3d492c-4a5e-4a56-a773-e8078e14476a£abs�Ù$23ee2544-2a2f-4302-8a62-2dd868cbb5d1„´precedence_heuristic §cell_idÙ$23ee2544-2a2f-4302-8a62-2dd868cbb5d1´downstream_cells_map�«response_2d‘Ù$a01c7aad-429d-447b-8943-a4e89dbac6f6²upstream_cells_map�§missing�Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88„´precedence_heuristic §cell_idÙ$69ca76b8-8766-47fe-89d6-31fcc7a60e88´downstream_cells_map�«response_1f•Ù$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04aÙ$ccdf5418-12e4-49ee-bdea-90efc202583aÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8²upstream_cells_map€Ù$18106638-c96c-47d6-990d-b35b6b0ba218„´precedence_heuristic §cell_idÙ$18106638-c96c-47d6-990d-b35b6b0ba218´downstream_cells_map�´histogram_or_density’Ù$1eb1face-a795-4cb3-9c51-f995f73e2509Ù$915fc532-7d8d-4ff5-81fd-af8f6e9e64da²upstream_cells_map�§@md_str�¤Core�©histogram�¨Base.get�¥@bind�¢=>�¤Base�«PlutoRunner�·PlutoRunner.create_bond�§density�¯Core.applicable�¦Select�¨getindex�Ù$f90594d8-92a1-4b0b-93d0-0e41e76b3f55„´precedence_heuristic §cell_idÙ$f90594d8-92a1-4b0b-93d0-0e41e76b3f55´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$aaa80da1-f7de-42ed-9691-c367e6bd9a28„´precedence_heuristic §cell_idÙ$aaa80da1-f7de-42ed-9691-c367e6bd9a28´downstream_cells_map€²upstream_cells_map�¯TableOfContents�Ù$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18„´precedence_heuristic §cell_idÙ$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18´downstream_cells_map€²upstream_cells_mapƒ«response_1f‘Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88©ismissing�still_missing�Ù$92ca099c-b81b-4cfe-a3fa-60833657f4ef„´precedence_heuristic §cell_idÙ$92ca099c-b81b-4cfe-a3fa-60833657f4ef´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$03fc47ea-9246-4cb8-8398-612fc2fb09fa„´precedence_heuristic §cell_idÙ$03fc47ea-9246-4cb8-8398-612fc2fb09fa´downstream_cells_map�«response_1b‘Ù$0c0312da-558a-4bc1-9e4a-b02ecd1c0572²upstream_cells_map�§missing�Ù$d3db2bc4-a26b-4e01-a193-b155a92dab48„´precedence_heuristic §cell_idÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48´downstream_cells_map�Ù model_hubble_law_lognormal_prior‘Ù$6c86d0f1-5c6f-4204-9414-60577164f4b8²upstream_cells_mapÞ ©LogNormal�§missing�ªBase.throw�¨MvNormal�¦@model�§@assert�¡!�¤Hâ‚€�¤size�£Any�ªNamedTuple�¤Base�£===�£log�¡/�¢==�³Base.AssertionError�Ù$9db3ff24-6f54-4a37-b787-de4b14694d95„´precedence_heuristic §cell_idÙ$9db3ff24-6f54-4a37-b787-de4b14694d95´downstream_cells_map�¿calc_fisher_matrix_linear_model‘Ù$c086c05f-ad73-44c7-bf8b-a304d3533690²upstream_cells_mapÞ ¤@doc�ªBase.throw�®AbstractMatrix�§@assert�¥Tuple�º#___this_pluto_module_name�¤size�§adjoint�¤Base�¡\�¢>=�¡*�¥Union�¢==�¤conj�³Base.AssertionError�Ù$c6af6d4a-ff58-4012-b4b2-4e3b09d53638„´precedence_heuristic §cell_idÙ$c6af6d4a-ff58-4012-b4b2-4e3b09d53638´downstream_cells_map€²upstream_cells_mapƒ«response_1h‘Ù$22da4ae4-6aea-4d45-ab2c-6fe935783e41©ismissing�still_missing�Ù$0c0312da-558a-4bc1-9e4a-b02ecd1c0572„´precedence_heuristic §cell_idÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572´downstream_cells_map€²upstream_cells_mapƒ«response_1b‘Ù$03fc47ea-9246-4cb8-8398-612fc2fb09fa©ismissing�still_missing�Ù$b15b1913-d265-4a35-b43e-67df53c93329„´precedence_heuristic §cell_idÙ$b15b1913-d265-4a35-b43e-67df53c93329´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$4655178c-a633-4b50-8f92-6ee028e21d0e„´precedence_heuristic §cell_idÙ$4655178c-a633-4b50-8f92-6ee028e21d0e´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$3bdb27da-451c-4260-bf43-5568985d24f2„´precedence_heuristic §cell_idÙ$3bdb27da-451c-4260-bf43-5568985d24f2´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2f7c11e8-d429-41eb-873e-ae554e028195„´precedence_heuristic §cell_idÙ$2f7c11e8-d429-41eb-873e-ae554e028195´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$8764ccfe-81cd-4bff-985a-c112fc5c902f„´precedence_heuristic §cell_idÙ$8764ccfe-81cd-4bff-985a-c112fc5c902f´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$b7e2903b-be56-4e36-885f-e16a9ddc94c6„´precedence_heuristic §cell_idÙ$b7e2903b-be56-4e36-885f-e16a9ddc94c6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$4eb123a1-f976-4fad-9a96-e3a61bdbf264„´precedence_heuristic §cell_idÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264´downstream_cells_map�«response_2a‘Ù$33045766-a7c5-42ff-bdf8-bde1fce9c56b²upstream_cells_map�§missing�Ù$089c50b6-5494-4f27-af3e-a8af972e2869„´precedence_heuristic §cell_idÙ$089c50b6-5494-4f27-af3e-a8af972e2869´downstream_cells_map�«response_2c‘Ù$fb2545e1-d624-4669-9e07-c94a598ba8ed²upstream_cells_map�§missing�Ù$34ccd3d7-e914-4f6f-a8eb-f421ed17e709„´precedence_heuristic §cell_idÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$e02dd163-59bc-4d48-ae43-6fc559536aa6„´precedence_heuristic §cell_idÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$a56871c9-affa-4612-b3f5-66363720f274„´precedence_heuristic §cell_idÙ$a56871c9-affa-4612-b3f5-66363720f274´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$4f27d8d1-0d14-49e5-abee-9f277369a78b„´precedence_heuristic §cell_idÙ$4f27d8d1-0d14-49e5-abee-9f277369a78b´downstream_cells_map�¾model_hubble_law_uniform_prior‘Ù$340dc0ff-dd1c-44e0-907c-f357adb122d5²upstream_cells_mapÞ §missing�ªBase.throw�¨MvNormal�¦@model�§@assert�¡!�§Uniform�¤Hâ‚€�¤size�£Any�ªNamedTuple�¤Base�¡-�²speed_of_light_mps‘Ù$a7d8f517-4117-4585-8089-117510c944c5£===�¡/�¢==�³Base.AssertionError�Ù$0144843f-b649-4ea2-a546-e8c14a928670„´precedence_heuristic §cell_idÙ$0144843f-b649-4ea2-a546-e8c14a928670´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$a7d8f517-4117-4585-8089-117510c944c5„´precedence_heuristic §cell_idÙ$a7d8f517-4117-4585-8089-117510c944c5´downstream_cells_map�²speed_of_light_mps’Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9Ù$4f27d8d1-0d14-49e5-abee-9f277369a78b²upstream_cells_map€Ù$18dd7cac-fac3-4c40-9230-f6387e41751b„´precedence_heuristic §cell_idÙ$18dd7cac-fac3-4c40-9230-f6387e41751b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$fa745b36-7465-443e-9f50-c786fe418c6a„´precedence_heuristic §cell_idÙ$fa745b36-7465-443e-9f50-c786fe418c6a´downstream_cells_map�¦Î£_all’Ù$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$1d70572f-214e-4161-b804-2c3b7c077c56²upstream_cells_mapƒ¡^�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¨PDiagMat�Ù$b4a68a89-bd1f-49d5-adb2-6239317a8b82„´precedence_heuristic §cell_idÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82´downstream_cells_map�§wls_all‘Ù$d67f0b9e-10be-4511-93ab-edceb3aef49c²upstream_cells_map…§weights�´formula_wo_intercept‘Ù$2656d886-60dc-44a7-b318-100335dcf05b¡^�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¢lm�Ù$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6„´precedence_heuristic §cell_idÙ$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$c433e938-31f7-4417-b3c0-a2f49fea8640„´precedence_heuristic §cell_idÙ$c433e938-31f7-4417-b3c0-a2f49fea8640´downstream_cells_map�±ready_to_run_mcmc’Ù$276a850b-09da-41f0-8661-5d63bb2afdf8Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3²upstream_cells_mapФCore�§@md_str�¤Base�·PlutoRunner.create_bond�«PlutoRunner�¨CheckBox�¯Core.applicable�¥@bind�¨Base.get�¨getindex�Ù$3aba1134-7c60-41f6-a1ac-73306efb7824„´precedence_heuristic §cell_idÙ$3aba1134-7c60-41f6-a1ac-73306efb7824´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$5e635a20-e205-48f0-908d-cb6d0c55b43b„´precedence_heuristic §cell_idÙ$5e635a20-e205-48f0-908d-cb6d0c55b43b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8„´precedence_heuristic §cell_idÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8´downstream_cells_map†«Hâ‚€inv_fit�¦Î£_fit�«Ïƒ_Hâ‚€_fit‘Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0a¥A_fit�¨Hâ‚€_fit‘Ù$ccdf5418-12e4-49ee-bdea-90efc202583a®Ïƒ_Hâ‚€inv_fit�²upstream_cells_map�¡!�«response_1f‘Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88©ismissing�¦df_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547db¤size�¨PDiagMat�µcalc_mle_linear_model‘Ù$556d8f17-8a03-42c8-82c7-52c8125b604d§reshape�¡/�¡^�»calc_sigma_mle_linear_model‘Ù$c086c05f-ad73-44c7-bf8b-a304d3533690¡*�£abs�Ù$7be54420-b2ec-4ef4-adc8-848817305d07„´precedence_heuristic §cell_idÙ$7be54420-b2ec-4ef4-adc8-848817305d07´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$16b0a2c1-5803-4310-9ee7-884b1333fb74„´precedence_heuristic §cell_idÙ$16b0a2c1-5803-4310-9ee7-884b1333fb74´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$0c20b9a7-69a9-49c8-9ba4-45b8770393d0„´precedence_heuristic §cell_idÙ$0c20b9a7-69a9-49c8-9ba4-45b8770393d0´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9„´precedence_heuristic§cell_idÙ$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9´downstream_cells_map�£CSV‘Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5©Downloads‘Ù$3f2ef930-d367-11ef-3b5c-95b4989c2e21©StatsBase�ªMCMCChains�¦PDMats�Distributions�¥Plots�§PlutoUI’Ù$d70d95e9-f0e7-4225-8e06-80735278cbcaÙ$2482544e-ad05-495c-9787-0797939445beªStatsPlots�²PlutoTeachingTools�LinearAlgebra�ªDataFrames�¦Turing�¬LaTeXStrings�£GLM�²upstream_cells_map€Ù$d70d95e9-f0e7-4225-8e06-80735278cbca„´precedence_heuristic §cell_idÙ$d70d95e9-f0e7-4225-8e06-80735278cbca´downstream_cells_mapƒ©plt_resid‘Ù$316f65a1-9062-4cb0-a3fb-af54149afb4d¨plt_yerr‘Ù$316f65a1-9062-4cb0-a3fb-af54149afb4dªHâ‚€_plt_1‘Ù$316f65a1-9062-4cb0-a3fb-af54149afb4d²upstream_cells_map�§@md_str�®PlutoUI.Slider�¡:�¤Core�§PlutoUI‘Ù$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9¨Base.get�¥@bind�°PlutoUI.CheckBox�¤Base�«PlutoRunner�·PlutoRunner.create_bond�¯Core.applicable�¨getindex�Ù$9f4d8983-d2d7-4bc9-bb31-5460a18dac5b„´precedence_heuristic §cell_idÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5b´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$22da4ae4-6aea-4d45-ab2c-6fe935783e41„´precedence_heuristic §cell_idÙ$22da4ae4-6aea-4d45-ab2c-6fe935783e41´downstream_cells_map�«response_1h‘Ù$c6af6d4a-ff58-4012-b4b2-4e3b09d53638²upstream_cells_map�§missing�Ù$a8f89fe8-110b-452e-9ecb-53769aa02a2e„´precedence_heuristic §cell_idÙ$a8f89fe8-110b-452e-9ecb-53769aa02a2e´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$a01c7aad-429d-447b-8943-a4e89dbac6f6„´precedence_heuristic §cell_idÙ$a01c7aad-429d-447b-8943-a4e89dbac6f6´downstream_cells_map€²upstream_cells_mapƒ«response_2d‘Ù$23ee2544-2a2f-4302-8a62-2dd868cbb5d1©ismissing�still_missing�Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3„´precedence_heuristic §cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3´downstream_cells_map�µchain_lognormal_prior’Ù$18edb530-8472-4932-946c-917d8ab9dbdeÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64da²upstream_cells_mapˆ°num_mcmc_samples‘Ù$2c1c7d8a-eda6-4900-9be7-e4b908fed81a¤NUTS�ªnum_chains‘Ù$2c1c7d8a-eda6-4900-9be7-e4b908fed81a«MCMCThreads�¦sample�±ready_to_run_mcmc‘Ù$c433e938-31f7-4417-b3c0-a2f49fea8640Ù+model_hubble_law_lognormal_prior_given_data‘Ù$6c86d0f1-5c6f-4204-9414-60577164f4b8§nothing�Ù$098afd51-2c39-42ef-91bf-cfc326827ea1„´precedence_heuristic §cell_idÙ$098afd51-2c39-42ef-91bf-cfc326827ea1´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d95d2e2d-c6ff-4cab-8b49-432ef61065bc„´precedence_heuristic §cell_idÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bc´downstream_cells_map€²upstream_cells_map„³plot_hubble_diagram‘Ù$2b3729fc-62b2-478d-b35c-e69e6b0efc93«Hâ‚€_bf_all‘Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70¦title!�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9Ù$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479„´precedence_heuristic §cell_idÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$78eb6aff-3752-41d8-a4d9-0cc2b31fd56d„´precedence_heuristic §cell_idÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$ac47f631-787d-4a3c-96cf-5fee86a3b2f4„´precedence_heuristic §cell_idÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4´downstream_cells_map�¬Hâ‚€_ols_all�²upstream_cells_mapƒ¡/�¤coef�§ols_all‘Ù$8ddbc921-4541-4c45-90c5-5c51ec2e391aÙ$42366f09-d437-4ba2-93ec-f7b8278eb09d„´precedence_heuristic §cell_idÙ$42366f09-d437-4ba2-93ec-f7b8278eb09d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d0f003fa-f72d-4a6f-ba60-1cad3844ef6a„´precedence_heuristic §cell_idÙ$d0f003fa-f72d-4a6f-ba60-1cad3844ef6a´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$f0220da0-6f3a-438c-b533-acb346382418„´precedence_heuristic §cell_idÙ$f0220da0-6f3a-438c-b533-acb346382418´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$8bfe0413-782b-4244-8624-a9f95e393d17„´precedence_heuristic §cell_idÙ$8bfe0413-782b-4244-8624-a9f95e393d17´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$3ec3e49c-04ce-4ffa-b1ca-8c58df0307dd„´precedence_heuristic §cell_idÙ$3ec3e49c-04ce-4ffa-b1ca-8c58df0307dd´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$92238689-d9df-46c2-bd72-3fcc41a22594„´precedence_heuristic §cell_idÙ$92238689-d9df-46c2-bd72-3fcc41a22594´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d5c3923b-8515-4002-9d93-6768f087aef6„´precedence_heuristic §cell_idÙ$d5c3923b-8515-4002-9d93-6768f087aef6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$4f11d0e2-7126-47f1-865a-3474298597dc„´precedence_heuristic §cell_idÙ$4f11d0e2-7126-47f1-865a-3474298597dc´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$337a560b-49f3-4fc5-926f-1689911eacf2„´precedence_heuristic §cell_idÙ$337a560b-49f3-4fc5-926f-1689911eacf2´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6„´precedence_heuristic §cell_idÙ$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d81347d3-9246-42d9-9a85-42c773ef2a1d„´precedence_heuristic §cell_idÙ$d81347d3-9246-42d9-9a85-42c773ef2a1d´downstream_cells_map�®added_metadata‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9²upstream_cells_map„©metadata!�¥df_in‘Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5£url‘Ù$3f2ef930-d367-11ef-3b5c-95b4989c2e21¬colmetadata!�Ù$adf117fe-0f54-4f2a-b107-0635f56263f2„´precedence_heuristic §cell_idÙ$adf117fe-0f54-4f2a-b107-0635f56263f2´downstream_cells_map�«response_2e‘Ù$e0e610d7-a237-42ea-8706-8e09858fba03²upstream_cells_map�§missing�Ù$2ad2563a-8a72-47e8-a36d-f6d2a49cb517„´precedence_heuristic §cell_idÙ$2ad2563a-8a72-47e8-a36d-f6d2a49cb517´downstream_cells_map‚³Hâ‚€_posterior_mean�²Hâ‚€_posterior_std�²upstream_cells_map†£vec�³chain_uniform_prior‘Ù$276a850b-09da-41f0-8661-5d63bb2afdf8¬mean_and_std�¢==�¢!=�§nothing�Ù$c086c05f-ad73-44c7-bf8b-a304d3533690„´precedence_heuristic §cell_idÙ$c086c05f-ad73-44c7-bf8b-a304d3533690´downstream_cells_map�»calc_sigma_mle_linear_model’Ù$1d70572f-214e-4161-b804-2c3b7c077c56Ù$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8²upstream_cells_mapÞ ¤@doc�£inv�¤diag�ªBase.throw�®AbstractMatrix�§@assert�¥Tuple�¤sqrt�º#___this_pluto_module_name�¤size�¿calc_fisher_matrix_linear_model‘Ù$9db3ff24-6f54-4a37-b787-de4b14694d95¤Base�¥PDMat�¢>=�¥Union�¢==�³Base.AssertionError�Ù$0a4aaa8a-20da-486f-ace5-fbadcf646609„´precedence_heuristic §cell_idÙ$0a4aaa8a-20da-486f-ace5-fbadcf646609´downstream_cells_map€²upstream_cells_map…¨describe�³chain_uniform_prior‘Ù$276a850b-09da-41f0-8661-5d63bb2afdf8¢!=�¢==�§nothing�Ù$eb72dda6-69f0-4538-a75a-25967653759f„´precedence_heuristic §cell_idÙ$eb72dda6-69f0-4538-a75a-25967653759f´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2d97268e-560b-4398-982e-1cf5cd9ab7dd„´precedence_heuristic §cell_idÙ$2d97268e-560b-4398-982e-1cf5cd9ab7dd´downstream_cells_map€²upstream_cells_mapƒ©ismissing�«response_2b‘Ù$0236d055-0d6d-440d-a44b-0d5cb0ab2273still_missing�Ù$28b844a8-650a-47d8-b9f6-586f22d6f603„´precedence_heuristic §cell_idÙ$28b844a8-650a-47d8-b9f6-586f22d6f603´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$c78f0ad9-03c0-4066-a390-193e7bfa84b1„´precedence_heuristic §cell_idÙ$c78f0ad9-03c0-4066-a390-193e7bfa84b1´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$1c35257a-9b98-4af6-bde0-a945665c91cd„´precedence_heuristic §cell_idÙ$1c35257a-9b98-4af6-bde0-a945665c91cd´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$751eff6b-2ed2-4073-b8b5-02ad9981edb6„´precedence_heuristic §cell_idÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6´downstream_cells_map�«response_1i‘Ù$e4597b96-6e06-44c2-a845-3d9967d2423c²upstream_cells_map�§missing�Ù$5974dfc3-8416-4bae-91de-d3f0a4f0c7db„´precedence_heuristic §cell_idÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7db´downstream_cells_map€²upstream_cells_mapƒ«response_1a‘Ù$25ef65bd-8b86-4f88-b0b7-32f05ce82ada©ismissing�still_missing�Ù$20f739ff-cc5b-460e-851a-141003d0c9d0„´precedence_heuristic §cell_idÙ$20f739ff-cc5b-460e-851a-141003d0c9d0´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70„´precedence_heuristic §cell_idÙ$f76f4c3c-74f1-44b0-9b3a-5895aec22e70´downstream_cells_map�«Hâ‚€_bf_all”Ù$d95d2e2d-c6ff-4cab-8b49-432ef61065bcÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04aÙ$1d70572f-214e-4161-b804-2c3b7c077c56²upstream_cells_map‚¡/�®Hâ‚€inv_bf_all‘Ù$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$a98ace81-9afd-4618-88a6-fadaf04eb364„´precedence_heuristic §cell_idÙ$a98ace81-9afd-4618-88a6-fadaf04eb364´downstream_cells_map€²upstream_cells_mapƒ«response_1d‘Ù$0c25a4cc-9f53-4729-985b-de692278c433©ismissing�still_missing�Ù$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1„´precedence_heuristic §cell_idÙ$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1´downstream_cells_map�«response_1e‘Ù$629dae3a-46ec-40dc-b9ed-92de9eb21adb²upstream_cells_map�§missing�Ù$95bc4b33-d619-4a95-af19-5771d209336d„´precedence_heuristic §cell_idÙ$95bc4b33-d619-4a95-af19-5771d209336d´downstream_cells_mapƒ¥topic’Ù$e09e30f7-838f-4571-bb9c-6d0b425807a8Ù$bf7ca6ea-4c07-46e4-baff-b205e1663505¥title’Ù$e09e30f7-838f-4571-bb9c-6d0b425807a8Ù$bf7ca6ea-4c07-46e4-baff-b205e1663505¤week‘Ù$e09e30f7-838f-4571-bb9c-6d0b425807a8²upstream_cells_map€Ù$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0„´precedence_heuristic §cell_idÙ$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2532e9de-8fa7-44ce-8502-c2473928aa8e„´precedence_heuristic §cell_idÙ$2532e9de-8fa7-44ce-8502-c2473928aa8e´downstream_cells_map€²upstream_cells_map�WidthOverDocs�Ù$4a2c109d-8e18-4561-913b-769f7eaeb6e9„´precedence_heuristic §cell_idÙ$4a2c109d-8e18-4561-913b-769f7eaeb6e9´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2f3d492c-4a5e-4a56-a773-e8078e14476a„´precedence_heuristic §cell_idÙ$2f3d492c-4a5e-4a56-a773-e8078e14476a´downstream_cells_map�®Hâ‚€inv_bf_all’Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70Ù$1d70572f-214e-4161-b804-2c3b7c077c56²upstream_cells_map„µcalc_mle_linear_model‘Ù$556d8f17-8a03-42c8-82c7-52c8125b604d¥A_all‘Ù$d9058d92-b1c9-44f2-af5c-3540932dec48¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¦Î£_all‘Ù$fa745b36-7465-443e-9f50-c786fe418c6aÙ$c43f2686-da2d-4b67-b87e-7c22bd09257c„´precedence_heuristic §cell_idÙ$c43f2686-da2d-4b67-b87e-7c22bd09257c´downstream_cells_map�«response_1g‘Ù$3a06141a-a92d-4c31-9950-13f0bf2c023a²upstream_cells_map�§missing�Ù$b54f8319-dce6-4009-873e-bd47dc2a4619„´precedence_heuristic §cell_idÙ$b54f8319-dce6-4009-873e-bd47dc2a4619´downstream_cells_map€²upstream_cells_map‰¦string�³plot_hubble_diagram‘Ù$2b3729fc-62b2-478d-b35c-e69e6b0efc93¥floor�¦title!�£Int�¡*�¬Hâ‚€_wls_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547db¦df_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547db©max_v_plt‘Ù$2482544e-ad05-495c-9787-0797939445beÙ$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7„´precedence_heuristic §cell_idÙ$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$a6cf5e52-8692-4e3c-95aa-11167b118bd4„´precedence_heuristic §cell_idÙ$a6cf5e52-8692-4e3c-95aa-11167b118bd4´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$0f6aa1eb-2f89-400f-b1e8-bfc07012179d„´precedence_heuristic §cell_idÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$0991f15c-b734-480b-8b12-6d2beda547db„´precedence_heuristic §cell_idÙ$0991f15c-b734-480b-8b12-6d2beda547db´downstream_cells_mapƒ§wls_fit�¬Hâ‚€_wls_fit’Ù$b54f8319-dce6-4009-873e-bd47dc2a4619Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0a¦df_fit–Ù$b54f8319-dce6-4009-873e-bd47dc2a4619Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$ccdf5418-12e4-49ee-bdea-90efc202583aÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8Ù$340dc0ff-dd1c-44e0-907c-f357adb122d5Ù$6c86d0f1-5c6f-4204-9414-60577164f4b8²upstream_cells_mapŠ¢<=�§weights�´formula_wo_intercept‘Ù$2656d886-60dc-44a7-b318-100335dcf05b¡^�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¡/�¢lm�¤coef�¦filter�©max_v_plt‘Ù$2482544e-ad05-495c-9787-0797939445beÙ$5c9b0395-4d2e-4679-8d86-b9581fa0f66c„´precedence_heuristic §cell_idÙ$5c9b0395-4d2e-4679-8d86-b9581fa0f66c´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$340dc0ff-dd1c-44e0-907c-f357adb122d5„´precedence_heuristic §cell_idÙ$340dc0ff-dd1c-44e0-907c-f357adb122d5´downstream_cells_map�Ù)model_hubble_law_uniform_prior_given_data‘Ù$276a850b-09da-41f0-8661-5d63bb2afdf8²upstream_cells_map‚¾model_hubble_law_uniform_prior‘Ù$4f27d8d1-0d14-49e5-abee-9f277369a78b¦df_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547dbÙ$0c25a4cc-9f53-4729-985b-de692278c433„´precedence_heuristic §cell_idÙ$0c25a4cc-9f53-4729-985b-de692278c433´downstream_cells_map�«response_1d‘Ù$a98ace81-9afd-4618-88a6-fadaf04eb364²upstream_cells_map�§missing�Ù$ad758d43-b135-418e-a29c-36cea3a24457„´precedence_heuristic §cell_idÙ$ad758d43-b135-418e-a29c-36cea3a24457´downstream_cells_map€²upstream_cells_map„§@md_str�¥aside�£tip�¨getindex�Ù$18edb530-8472-4932-946c-917d8ab9dbde„´precedence_heuristic §cell_idÙ$18edb530-8472-4932-946c-917d8ab9dbde´downstream_cells_map€²upstream_cells_map…µchain_lognormal_prior‘Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¨describe�¢!=�¢==�§nothing�Ù$2b3729fc-62b2-478d-b35c-e69e6b0efc93„´precedence_heuristic §cell_idÙ$2b3729fc-62b2-478d-b35c-e69e6b0efc93´downstream_cells_map�³plot_hubble_diagram“Ù$316f65a1-9062-4cb0-a3fb-af54149afb4dÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bcÙ$b54f8319-dce6-4009-873e-bd47dc2a4619²upstream_cells_mapÞ ¦string�§@assert�¥Tuple�¤Real�¦length�¥names�¥range�¡/�£âˆˆ�¢in�¥round�¨scatter!�³Base.AssertionError�¤@doc�ªBase.throw�¤Bool�º#___this_pluto_module_name�¤size�§xlabel!�´predict_linear_model‘Ù$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861±AbstractDataFrame�¤Base�¡-�§reshape�¢>=�¤plot�¡*�¥Union�§maximum�§ylabel!�Ù$92af3764-6c53-4e03-a338-81b1de202a04„´precedence_heuristic §cell_idÙ$92af3764-6c53-4e03-a338-81b1de202a04´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$0a998eb0-4bf5-4d4e-b193-54964b54f1ab„´precedence_heuristic §cell_idÙ$0a998eb0-4bf5-4d4e-b193-54964b54f1ab´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$8ab41174-d7d9-42c7-8129-381c54906280„´precedence_heuristic §cell_idÙ$8ab41174-d7d9-42c7-8129-381c54906280´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7f61c098-1c54-4c82-be40-f9fd154156a1„´precedence_heuristic §cell_idÙ$7f61c098-1c54-4c82-be40-f9fd154156a1´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§details�¨getindex�Ù$ef78506f-0326-4bd0-8fb3-af6f34a06841„´precedence_heuristic §cell_idÙ$ef78506f-0326-4bd0-8fb3-af6f34a06841´downstream_cells_map€²upstream_cells_map„§@md_str�¥aside�£tip�¨getindex�Ù$316f65a1-9062-4cb0-a3fb-af54149afb4d„´precedence_heuristic §cell_idÙ$316f65a1-9062-4cb0-a3fb-af54149afb4d´downstream_cells_map€²upstream_cells_map…©plt_resid‘Ù$d70d95e9-f0e7-4225-8e06-80735278cbca³plot_hubble_diagram‘Ù$2b3729fc-62b2-478d-b35c-e69e6b0efc93¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¨plt_yerr‘Ù$d70d95e9-f0e7-4225-8e06-80735278cbcaªHâ‚€_plt_1‘Ù$d70d95e9-f0e7-4225-8e06-80735278cbcaÙ$8ddbc921-4541-4c45-90c5-5c51ec2e391a„´precedence_heuristic §cell_idÙ$8ddbc921-4541-4c45-90c5-5c51ec2e391a´downstream_cells_map�§ols_all‘Ù$ac47f631-787d-4a3c-96cf-5fee86a3b2f4²upstream_cells_mapˆ«StatsModels�¡~�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¡+�¢lm�¸StatsModels.ConstantTerm�¨@formula�°StatsModels.Term�Ù$d67f0b9e-10be-4511-93ab-edceb3aef49c„´precedence_heuristic §cell_idÙ$d67f0b9e-10be-4511-93ab-edceb3aef49c´downstream_cells_map�¬Hâ‚€_wls_all‘Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0a²upstream_cells_mapƒ§wls_all‘Ù$b4a68a89-bd1f-49d5-adb2-6239317a8b82¡/�¤coef�Ù$1eb1face-a795-4cb3-9c51-f995f73e2509„´precedence_heuristic §cell_idÙ$1eb1face-a795-4cb3-9c51-f995f73e2509´downstream_cells_map€²upstream_cells_mapŒ§minimum�³chain_uniform_prior‘Ù$276a850b-09da-41f0-8661-5d63bb2afdf8¤ceil�§xlabel!�§nothing�¥floor�¥range�¦title!�¢!=�¢==�´histogram_or_density‘Ù$18106638-c96c-47d6-990d-b35b6b0ba218§maximum�Ù$ccdf5418-12e4-49ee-bdea-90efc202583a„´precedence_heuristic §cell_idÙ$ccdf5418-12e4-49ee-bdea-90efc202583a´downstream_cells_map€²upstream_cells_mapŒ¡!�¤sqrt�«response_1f‘Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88¨Hâ‚€_fit‘Ù$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8©ismissing�¦df_fit‘Ù$0991f15c-b734-480b-8b12-6d2beda547db¤loss‘Ù$77b17593-6a28-4294-9b17-41303d57d5a9¡-�¡/�¡^�¡+�¡*�Ù$2efb7fb2-0402-4eec-b58a-a52fd530e3f5„´precedence_heuristic §cell_idÙ$2efb7fb2-0402-4eec-b58a-a52fd530e3f5´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$3a06141a-a92d-4c31-9950-13f0bf2c023a„´precedence_heuristic §cell_idÙ$3a06141a-a92d-4c31-9950-13f0bf2c023a´downstream_cells_map€²upstream_cells_mapƒstill_missing�©ismissing�«response_1g‘Ù$c43f2686-da2d-4b67-b87e-7c22bd09257cÙ$bf7ca6ea-4c07-46e4-baff-b205e1663505„´precedence_heuristic §cell_idÙ$bf7ca6ea-4c07-46e4-baff-b205e1663505´downstream_cells_map€²upstream_cells_map„§@md_str�¥topic‘Ù$95bc4b33-d619-4a95-af19-5771d209336d¥title‘Ù$95bc4b33-d619-4a95-af19-5771d209336d¨getindex�Ù$2656d886-60dc-44a7-b318-100335dcf05b„´precedence_heuristic §cell_idÙ$2656d886-60dc-44a7-b318-100335dcf05b´downstream_cells_map�´formula_wo_intercept’Ù$b4a68a89-bd1f-49d5-adb2-6239317a8b82Ù$0991f15c-b734-480b-8b12-6d2beda547db²upstream_cells_map†«StatsModels�¡~�¡+�¸StatsModels.ConstantTerm�°StatsModels.Term�¨@formula�Ù$2c1c7d8a-eda6-4900-9be7-e4b908fed81a„´precedence_heuristic §cell_idÙ$2c1c7d8a-eda6-4900-9be7-e4b908fed81a´downstream_cells_map‚°num_mcmc_samples’Ù$276a850b-09da-41f0-8661-5d63bb2afdf8Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3ªnum_chains’Ù$276a850b-09da-41f0-8661-5d63bb2afdf8Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3²upstream_cells_map€Ù$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861„´precedence_heuristic §cell_idÙ$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861´downstream_cells_map�´predict_linear_model‘Ù$2b3729fc-62b2-478d-b35c-e69e6b0efc93²upstream_cells_mapޤ@doc�ªBase.throw�®AbstractVector�®AbstractMatrix�§@assert�¥Tuple�º#___this_pluto_module_name�¤size�¦length�¤Base�¡*�¥Union�¢==�³Base.AssertionError�Ù$9ef67704-5063-4f75-853b-078261e50684„´precedence_heuristic §cell_idÙ$9ef67704-5063-4f75-853b-078261e50684´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$095bdd00-ffa9-434d-9fc5-0978019b060b„´precedence_heuristic §cell_idÙ$095bdd00-ffa9-434d-9fc5-0978019b060b´downstream_cells_map€²upstream_cells_map€Ù$3f2ef930-d367-11ef-3b5c-95b4989c2e21„´precedence_heuristic §cell_idÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21´downstream_cells_map‚¨filename‘Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5£url‘Ù$d81347d3-9246-42d9-9a85-42c773ef2a1d²upstream_cells_mapÞ ©Downloads‘Ù$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9²Downloads.download�§@assert�¨filesize�¨joinpath�¦isless�¡>�¡!�£end�¡<�£pwd�¥throw�®AssertionError�¦mkpath�¡*�¢==�¥split�Ù$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3„´precedence_heuristic §cell_idÙ$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3´downstream_cells_map�«response_1c‘Ù$0e42628b-95a9-45a0-b375-51f62dc0ce0d²upstream_cells_map�§missing�Ù$ac1a64e8-7a5c-43b5-923a-633dac4fb664„´precedence_heuristic §cell_idÙ$ac1a64e8-7a5c-43b5-923a-633dac4fb664´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d9058d92-b1c9-44f2-af5c-3540932dec48„´precedence_heuristic §cell_idÙ$d9058d92-b1c9-44f2-af5c-3540932dec48´downstream_cells_map�¥A_all’Ù$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$1d70572f-214e-4161-b804-2c3b7c077c56²upstream_cells_mapƒ§reshape�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¤size�Ù$0e42628b-95a9-45a0-b375-51f62dc0ce0d„´precedence_heuristic §cell_idÙ$0e42628b-95a9-45a0-b375-51f62dc0ce0d´downstream_cells_map€²upstream_cells_mapƒ«response_1c‘Ù$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3©ismissing�still_missing�Ù$e09e30f7-838f-4571-bb9c-6d0b425807a8„´precedence_heuristic §cell_idÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8´downstream_cells_map€²upstream_cells_map‡§@md_str�¤Base�¥topic‘Ù$95bc4b33-d619-4a95-af19-5771d209336d¢|>�¥title‘Ù$95bc4b33-d619-4a95-af19-5771d209336d¤week‘Ù$95bc4b33-d619-4a95-af19-5771d209336d¨getindex�Ù$a2b56e1c-9735-49b0-91da-40f489823390„´precedence_heuristic §cell_idÙ$a2b56e1c-9735-49b0-91da-40f489823390´downstream_cells_map€²upstream_cells_map„§@md_str�¥aside�£tip�¨getindex�Ù$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348„´precedence_heuristic §cell_idÙ$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$e4ca4972-42c8-4426-94ae-e316662513c3„´precedence_heuristic §cell_idÙ$e4ca4972-42c8-4426-94ae-e316662513c3´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$6a75dd68-5034-4b16-89a0-7388cfae0cbd„´precedence_heuristic §cell_idÙ$6a75dd68-5034-4b16-89a0-7388cfae0cbd´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d68dd4b4-c091-4435-a286-3de589b19009„´precedence_heuristic §cell_idÙ$d68dd4b4-c091-4435-a286-3de589b19009´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$33045766-a7c5-42ff-bdf8-bde1fce9c56b„´precedence_heuristic §cell_idÙ$33045766-a7c5-42ff-bdf8-bde1fce9c56b´downstream_cells_map€²upstream_cells_mapƒ«response_2a‘Ù$4eb123a1-f976-4fad-9a96-e3a61bdbf264©ismissing�still_missing�Ù$9555ae09-be3d-48e8-9ee2-face2bef8cce„´precedence_heuristic §cell_idÙ$9555ae09-be3d-48e8-9ee2-face2bef8cce´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$466dacda-1835-42fd-b8f4-cac5c22f6756„´precedence_heuristic §cell_idÙ$466dacda-1835-42fd-b8f4-cac5c22f6756´downstream_cells_map�¨ols_try1�²upstream_cells_map†«StatsModels�¡~�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¢lm�°StatsModels.Term�¨@formula�Ù$915fc532-7d8d-4ff5-81fd-af8f6e9e64da„´precedence_heuristic §cell_idÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64da´downstream_cells_map€²upstream_cells_map�§minimum�µchain_lognormal_prior‘Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¤vcat�³chain_uniform_prior‘Ù$276a850b-09da-41f0-8661-5d63bb2afdf8¤ceil�§xlabel!�§nothing�¥floor�¥range�¤plot�¦title!�¢!=�¢==�´histogram_or_density‘Ù$18106638-c96c-47d6-990d-b35b6b0ba218§maximum�Ù$fb2545e1-d624-4669-9e07-c94a598ba8ed„´precedence_heuristic §cell_idÙ$fb2545e1-d624-4669-9e07-c94a598ba8ed´downstream_cells_map€²upstream_cells_mapƒ«response_2c‘Ù$089c50b6-5494-4f27-af3e-a8af972e2869©ismissing�still_missing�Ù$67e9aa94-2d3a-4888-97b7-c2cb019eb04a„´precedence_heuristic §cell_idÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04a´downstream_cells_map€²upstream_cells_mapŒ«Hâ‚€_bf_all‘Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70¡!�¤sqrt�«response_1f‘Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88©ismissing�¤loss‘Ù$77b17593-6a28-4294-9b17-41303d57d5a9¡-�¡/�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¡+�¡^�¡*�Ù$389e8239-6f62-46fb-8b13-d336516e5e2f„´precedence_heuristic §cell_idÙ$389e8239-6f62-46fb-8b13-d336516e5e2f´downstream_cells_map€²upstream_cells_map†©LogNormal�£log�¦title!�¤plot�§xlabel!�§ylabel!�Ù$54b51239-59b0-4767-9bc8-018d77ee5e44„´precedence_heuristic §cell_idÙ$54b51239-59b0-4767-9bc8-018d77ee5e44´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$d62cf934-a592-482b-b0b3-7fd55f9e0617„´precedence_heuristic §cell_idÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$aab05339-dea2-4c7f-8b38-bc7d7971f1d9„´precedence_heuristic §cell_idÙ$aab05339-dea2-4c7f-8b38-bc7d7971f1d9´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$46eb1088-0265-46a6-91ec-44dfa3bd862d„´precedence_heuristic §cell_idÙ$46eb1088-0265-46a6-91ec-44dfa3bd862d´downstream_cells_map€²upstream_cells_map‚§scatter�¦df_all‘Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9Ù$25ef65bd-8b86-4f88-b0b7-32f05ce82ada„´precedence_heuristic §cell_idÙ$25ef65bd-8b86-4f88-b0b7-32f05ce82ada´downstream_cells_map�«response_1a‘Ù$5974dfc3-8416-4bae-91de-d3f0a4f0c7db²upstream_cells_map�§missing�´cell_execution_orderÜ ¡Ù$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9Ù$95bc4b33-d619-4a95-af19-5771d209336dÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8Ù$bf7ca6ea-4c07-46e4-baff-b205e1663505Ù$aaa80da1-f7de-42ed-9691-c367e6bd9a28Ù$a8f89fe8-110b-452e-9ecb-53769aa02a2eÙ$7be54420-b2ec-4ef4-adc8-848817305d07Ù$d19e7f11-d1ff-4624-8603-38ffec0c7beaÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21Ù$cd4fc36e-74f1-4b33-b92c-f0b7913a7203Ù$2efb7fb2-0402-4eec-b58a-a52fd530e3f5Ù$0735d5d6-9328-47f7-a764-24b4b8d92ca3Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5Ù$f0220da0-6f3a-438c-b533-acb346382418Ù$ef78506f-0326-4bd0-8fb3-af6f34a06841Ù$0a998eb0-4bf5-4d4e-b193-54964b54f1abÙ$d81347d3-9246-42d9-9a85-42c773ef2a1dÙ$b15b1913-d265-4a35-b43e-67df53c93329Ù$4655178c-a633-4b50-8f92-6ee028e21d0eÙ$92ca099c-b81b-4cfe-a3fa-60833657f4efÙ$daa349a6-545b-4dfc-a3b0-92884da98e5eÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5bÙ$1c35257a-9b98-4af6-bde0-a945665c91cdÙ$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0Ù$2f7c11e8-d429-41eb-873e-ae554e028195Ù$25ef65bd-8b86-4f88-b0b7-32f05ce82adaÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7dbÙ$18dd7cac-fac3-4c40-9230-f6387e41751bÙ$095bdd00-ffa9-434d-9fc5-0978019b060bÙ$03fc47ea-9246-4cb8-8398-612fc2fb09faÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572Ù$4a2c109d-8e18-4561-913b-769f7eaeb6e9Ù$3aba1134-7c60-41f6-a1ac-73306efb7824Ù$efde0b1e-ec47-4180-aba7-ed8843395b50Ù$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3Ù$0e42628b-95a9-45a0-b375-51f62dc0ce0dÙ$d70d95e9-f0e7-4225-8e06-80735278cbcaÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179dÙ$8ab41174-d7d9-42c7-8129-381c54906280Ù$77b17593-6a28-4294-9b17-41303d57d5a9Ù$beeeb261-4dcb-4093-b1cd-08682785eadeÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479Ù$098afd51-2c39-42ef-91bf-cfc326827ea1Ù$0c25a4cc-9f53-4729-985b-de692278c433Ù$a98ace81-9afd-4618-88a6-fadaf04eb364Ù$5c9b0395-4d2e-4679-8d86-b9581fa0f66cÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6Ù$92af3764-6c53-4e03-a338-81b1de202a04Ù$2786b37a-207f-4831-983e-81a380c37045Ù$ac1a64e8-7a5c-43b5-923a-633dac4fb664Ù$c6f03d5d-18e2-4491-90fe-fe0008f774c4Ù$6a75dd68-5034-4b16-89a0-7388cfae0cbdÙ$a2b56e1c-9735-49b0-91da-40f489823390Ù$9ef67704-5063-4f75-853b-078261e50684Ù$b7e2903b-be56-4e36-885f-e16a9ddc94c6Ù$f90594d8-92a1-4b0b-93d0-0e41e76b3f55Ù$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1Ù$629dae3a-46ec-40dc-b9ed-92de9eb21adbÙ$e4ca4972-42c8-4426-94ae-e316662513c3Ù$a7981271-0b12-4b75-b5f0-5e91af761419Ù$8bfe0413-782b-4244-8624-a9f95e393d17Ù$92238689-d9df-46c2-bd72-3fcc41a22594Ù$28b844a8-650a-47d8-b9f6-586f22d6f603Ù$2656d886-60dc-44a7-b318-100335dcf05bÙ$20f739ff-cc5b-460e-851a-141003d0c9d0Ù$9555ae09-be3d-48e8-9ee2-face2bef8cceÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709Ù$0c20b9a7-69a9-49c8-9ba4-45b8770393d0Ù$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88Ù$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18Ù$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7Ù$c43f2686-da2d-4b67-b87e-7c22bd09257cÙ$3a06141a-a92d-4c31-9950-13f0bf2c023aÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56dÙ$d68dd4b4-c091-4435-a286-3de589b19009Ù$3ec3e49c-04ce-4ffa-b1ca-8c58df0307ddÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617Ù$16b0a2c1-5803-4310-9ee7-884b1333fb74Ù$22da4ae4-6aea-4d45-ab2c-6fe935783e41Ù$c6af6d4a-ff58-4012-b4b2-4e3b09d53638Ù$42366f09-d437-4ba2-93ec-f7b8278eb09dÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6Ù$e4597b96-6e06-44c2-a845-3d9967d2423cÙ$5e635a20-e205-48f0-908d-cb6d0c55b43bÙ$3bdb27da-451c-4260-bf43-5568985d24f2Ù$4f11d0e2-7126-47f1-865a-3474298597dcÙ$ad758d43-b135-418e-a29c-36cea3a24457Ù$d3e82a29-c1b5-4f5a-ba96-a64d22636493Ù$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6Ù$d0f003fa-f72d-4a6f-ba60-1cad3844ef6aÙ$7f61c098-1c54-4c82-be40-f9fd154156a1Ù$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8Ù$a6cf5e52-8692-4e3c-95aa-11167b118bd4Ù$c433e938-31f7-4417-b3c0-a2f49fea8640Ù$54b51239-59b0-4767-9bc8-018d77ee5e44Ù$18106638-c96c-47d6-990d-b35b6b0ba218Ù$a56871c9-affa-4612-b3f5-66363720f274Ù$8764ccfe-81cd-4bff-985a-c112fc5c902fÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264Ù$33045766-a7c5-42ff-bdf8-bde1fce9c56bÙ$49090825-2843-4b3e-8ee6-658187232f96Ù$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6Ù$389e8239-6f62-46fb-8b13-d336516e5e2fÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48Ù$eb72dda6-69f0-4538-a75a-25967653759fÙ$0144843f-b649-4ea2-a546-e8c14a928670Ù$0236d055-0d6d-440d-a44b-0d5cb0ab2273Ù$2d97268e-560b-4398-982e-1cf5cd9ab7ddÙ$d5c3923b-8515-4002-9d93-6768f087aef6Ù$089c50b6-5494-4f27-af3e-a8af972e2869Ù$fb2545e1-d624-4669-9e07-c94a598ba8edÙ$337a560b-49f3-4fc5-926f-1689911eacf2Ù$23ee2544-2a2f-4302-8a62-2dd868cbb5d1Ù$a01c7aad-429d-447b-8943-a4e89dbac6f6Ù$c78f0ad9-03c0-4066-a390-193e7bfa84b1Ù$adf117fe-0f54-4f2a-b107-0635f56263f2Ù$e0e610d7-a237-42ea-8706-8e09858fba03Ù$48e246bc-4937-40d6-b686-73524f3ce057Ù$2532e9de-8fa7-44ce-8502-c2473928aa8eÙ$2c1c7d8a-eda6-4900-9be7-e4b908fed81aÙ$a7d8f517-4117-4585-8089-117510c944c5Ù$da9eb594-e0fe-4e9c-be69-4150c9a44fb9Ù$46eb1088-0265-46a6-91ec-44dfa3bd862dÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70eÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974bÙ$d9058d92-b1c9-44f2-af5c-3540932dec48Ù$fa745b36-7465-443e-9f50-c786fe418c6aÙ$466dacda-1835-42fd-b8f4-cac5c22f6756Ù$8ddbc921-4541-4c45-90c5-5c51ec2e391aÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4Ù$b4a68a89-bd1f-49d5-adb2-6239317a8b82Ù$d67f0b9e-10be-4511-93ab-edceb3aef49cÙ$2482544e-ad05-495c-9787-0797939445beÙ$0991f15c-b734-480b-8b12-6d2beda547dbÙ$6c86d0f1-5c6f-4204-9414-60577164f4b8Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3Ù$18edb530-8472-4932-946c-917d8ab9dbdeÙ$4f27d8d1-0d14-49e5-abee-9f277369a78bÙ$340dc0ff-dd1c-44e0-907c-f357adb122d5Ù$276a850b-09da-41f0-8661-5d63bb2afdf8Ù$1eb1face-a795-4cb3-9c51-f995f73e2509Ù$0a4aaa8a-20da-486f-ace5-fbadcf646609Ù$2ad2563a-8a72-47e8-a36d-f6d2a49cb517Ù$915fc532-7d8d-4ff5-81fd-af8f6e9e64daÙ$aab05339-dea2-4c7f-8b38-bc7d7971f1d9Ù$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861Ù$556d8f17-8a03-42c8-82c7-52c8125b604dÙ$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$f76f4c3c-74f1-44b0-9b3a-5895aec22e70Ù$67e9aa94-2d3a-4888-97b7-c2cb019eb04aÙ$9db3ff24-6f54-4a37-b787-de4b14694d95Ù$c086c05f-ad73-44c7-bf8b-a304d3533690Ù$1d70572f-214e-4161-b804-2c3b7c077c56Ù$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$ccdf5418-12e4-49ee-bdea-90efc202583aÙ$2b3729fc-62b2-478d-b35c-e69e6b0efc93Ù$316f65a1-9062-4cb0-a3fb-af54149afb4dÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bcÙ$b54f8319-dce6-4009-873e-bd47dc2a4619´last_hot_reload_timeË ©shortpath¦ex1.jl®process_status¥ready¤pathÙ"/home/runner/work/lab3/lab3/ex1.jlpluto_version¨v0.19.47®last_save_timeËAÙæœ,Ž\ªcell_orderÜ ¡Ù$95bc4b33-d619-4a95-af19-5771d209336dÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8Ù$bf7ca6ea-4c07-46e4-baff-b205e1663505Ù$aaa80da1-f7de-42ed-9691-c367e6bd9a28Ù$a8f89fe8-110b-452e-9ecb-53769aa02a2eÙ$7be54420-b2ec-4ef4-adc8-848817305d07Ù$d19e7f11-d1ff-4624-8603-38ffec0c7beaÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21Ù$cd4fc36e-74f1-4b33-b92c-f0b7913a7203Ù$2efb7fb2-0402-4eec-b58a-a52fd530e3f5Ù$0735d5d6-9328-47f7-a764-24b4b8d92ca3Ù$4518f1f7-a2a3-4783-86ae-4413fc4291b5Ù$f0220da0-6f3a-438c-b533-acb346382418Ù$ef78506f-0326-4bd0-8fb3-af6f34a06841Ù$0a998eb0-4bf5-4d4e-b193-54964b54f1abÙ$d81347d3-9246-42d9-9a85-42c773ef2a1dÙ$b15b1913-d265-4a35-b43e-67df53c93329Ù$4655178c-a633-4b50-8f92-6ee028e21d0eÙ$92ca099c-b81b-4cfe-a3fa-60833657f4efÙ$daa349a6-545b-4dfc-a3b0-92884da98e5eÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5bÙ$1c35257a-9b98-4af6-bde0-a945665c91cdÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9Ù$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0Ù$46eb1088-0265-46a6-91ec-44dfa3bd862dÙ$2f7c11e8-d429-41eb-873e-ae554e028195Ù$25ef65bd-8b86-4f88-b0b7-32f05ce82adaÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7dbÙ$18dd7cac-fac3-4c40-9230-f6387e41751bÙ$095bdd00-ffa9-434d-9fc5-0978019b060bÙ$03fc47ea-9246-4cb8-8398-612fc2fb09faÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572Ù$4a2c109d-8e18-4561-913b-769f7eaeb6e9Ù$3aba1134-7c60-41f6-a1ac-73306efb7824Ù$efde0b1e-ec47-4180-aba7-ed8843395b50Ù$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3Ù$0e42628b-95a9-45a0-b375-51f62dc0ce0dÙ$316f65a1-9062-4cb0-a3fb-af54149afb4dÙ$d70d95e9-f0e7-4225-8e06-80735278cbcaÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179dÙ$8ab41174-d7d9-42c7-8129-381c54906280Ù$77b17593-6a28-4294-9b17-41303d57d5a9Ù$beeeb261-4dcb-4093-b1cd-08682785eadeÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479Ù$0d0917aa-674e-47c4-a8dc-4d1585ebb70eÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974bÙ$098afd51-2c39-42ef-91bf-cfc326827ea1Ù$0c25a4cc-9f53-4729-985b-de692278c433Ù$a98ace81-9afd-4618-88a6-fadaf04eb364Ù$5c9b0395-4d2e-4679-8d86-b9581fa0f66cÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6Ù$92af3764-6c53-4e03-a338-81b1de202a04Ù$2786b37a-207f-4831-983e-81a380c37045Ù$ac1a64e8-7a5c-43b5-923a-633dac4fb664Ù$c6f03d5d-18e2-4491-90fe-fe0008f774c4Ù$6a75dd68-5034-4b16-89a0-7388cfae0cbdÙ$d9058d92-b1c9-44f2-af5c-3540932dec48Ù$fa745b36-7465-443e-9f50-c786fe418c6aÙ$a2b56e1c-9735-49b0-91da-40f489823390Ù$9ef67704-5063-4f75-853b-078261e50684Ù$2f3d492c-4a5e-4a56-a773-e8078e14476aÙ$b7e2903b-be56-4e36-885f-e16a9ddc94c6Ù$f76f4c3c-74f1-44b0-9b3a-5895aec22e70Ù$d95d2e2d-c6ff-4cab-8b49-432ef61065bcÙ$f90594d8-92a1-4b0b-93d0-0e41e76b3f55Ù$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1Ù$629dae3a-46ec-40dc-b9ed-92de9eb21adbÙ$e4ca4972-42c8-4426-94ae-e316662513c3Ù$a7981271-0b12-4b75-b5f0-5e91af761419Ù$8bfe0413-782b-4244-8624-a9f95e393d17Ù$466dacda-1835-42fd-b8f4-cac5c22f6756Ù$92238689-d9df-46c2-bd72-3fcc41a22594Ù$8ddbc921-4541-4c45-90c5-5c51ec2e391aÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4Ù$28b844a8-650a-47d8-b9f6-586f22d6f603Ù$2656d886-60dc-44a7-b318-100335dcf05bÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82Ù$d67f0b9e-10be-4511-93ab-edceb3aef49cÙ$20f739ff-cc5b-460e-851a-141003d0c9d0Ù$9555ae09-be3d-48e8-9ee2-face2bef8cceÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709Ù$0991f15c-b734-480b-8b12-6d2beda547dbÙ$0c20b9a7-69a9-49c8-9ba4-45b8770393d0Ù$b54f8319-dce6-4009-873e-bd47dc2a4619Ù$2482544e-ad05-495c-9787-0797939445beÙ$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348Ù$69ca76b8-8766-47fe-89d6-31fcc7a60e88Ù$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18Ù$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7Ù$c43f2686-da2d-4b67-b87e-7c22bd09257cÙ$3a06141a-a92d-4c31-9950-13f0bf2c023aÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56dÙ$d68dd4b4-c091-4435-a286-3de589b19009Ù$ce45a056-a949-4a9c-850e-9b5a997ecb0aÙ$3ec3e49c-04ce-4ffa-b1ca-8c58df0307ddÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04aÙ$ccdf5418-12e4-49ee-bdea-90efc202583aÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617Ù$1d70572f-214e-4161-b804-2c3b7c077c56Ù$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8Ù$16b0a2c1-5803-4310-9ee7-884b1333fb74Ù$22da4ae4-6aea-4d45-ab2c-6fe935783e41Ù$c6af6d4a-ff58-4012-b4b2-4e3b09d53638Ù$42366f09-d437-4ba2-93ec-f7b8278eb09dÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6Ù$e4597b96-6e06-44c2-a845-3d9967d2423cÙ$5e635a20-e205-48f0-908d-cb6d0c55b43bÙ$3bdb27da-451c-4260-bf43-5568985d24f2Ù$4f11d0e2-7126-47f1-865a-3474298597dcÙ$ad758d43-b135-418e-a29c-36cea3a24457Ù$4f27d8d1-0d14-49e5-abee-9f277369a78bÙ$d3e82a29-c1b5-4f5a-ba96-a64d22636493Ù$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6Ù$d0f003fa-f72d-4a6f-ba60-1cad3844ef6aÙ$7f61c098-1c54-4c82-be40-f9fd154156a1Ù$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8Ù$340dc0ff-dd1c-44e0-907c-f357adb122d5Ù$a6cf5e52-8692-4e3c-95aa-11167b118bd4Ù$c433e938-31f7-4417-b3c0-a2f49fea8640Ù$276a850b-09da-41f0-8661-5d63bb2afdf8Ù$54b51239-59b0-4767-9bc8-018d77ee5e44Ù$18106638-c96c-47d6-990d-b35b6b0ba218Ù$1eb1face-a795-4cb3-9c51-f995f73e2509Ù$a56871c9-affa-4612-b3f5-66363720f274Ù$0a4aaa8a-20da-486f-ace5-fbadcf646609Ù$8764ccfe-81cd-4bff-985a-c112fc5c902fÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264Ù$33045766-a7c5-42ff-bdf8-bde1fce9c56bÙ$49090825-2843-4b3e-8ee6-658187232f96Ù$2ad2563a-8a72-47e8-a36d-f6d2a49cb517Ù$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6Ù$389e8239-6f62-46fb-8b13-d336516e5e2fÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48Ù$6c86d0f1-5c6f-4204-9414-60577164f4b8Ù$cf6fbe84-9a51-4ddb-9def-c22893a17ed3Ù$18edb530-8472-4932-946c-917d8ab9dbdeÙ$eb72dda6-69f0-4538-a75a-25967653759fÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64daÙ$0144843f-b649-4ea2-a546-e8c14a928670Ù$0236d055-0d6d-440d-a44b-0d5cb0ab2273Ù$2d97268e-560b-4398-982e-1cf5cd9ab7ddÙ$d5c3923b-8515-4002-9d93-6768f087aef6Ù$089c50b6-5494-4f27-af3e-a8af972e2869Ù$fb2545e1-d624-4669-9e07-c94a598ba8edÙ$337a560b-49f3-4fc5-926f-1689911eacf2Ù$23ee2544-2a2f-4302-8a62-2dd868cbb5d1Ù$a01c7aad-429d-447b-8943-a4e89dbac6f6Ù$c78f0ad9-03c0-4066-a390-193e7bfa84b1Ù$adf117fe-0f54-4f2a-b107-0635f56263f2Ù$e0e610d7-a237-42ea-8706-8e09858fba03Ù$48e246bc-4937-40d6-b686-73524f3ce057Ù$2532e9de-8fa7-44ce-8502-c2473928aa8eÙ$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9Ù$2c1c7d8a-eda6-4900-9be7-e4b908fed81aÙ$a7d8f517-4117-4585-8089-117510c944c5Ù$aab05339-dea2-4c7f-8b38-bc7d7971f1d9Ù$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861Ù$556d8f17-8a03-42c8-82c7-52c8125b604dÙ$9db3ff24-6f54-4a37-b787-de4b14694d95Ù$c086c05f-ad73-44c7-bf8b-a304d3533690Ù$2b3729fc-62b2-478d-b35c-e69e6b0efc93±published_objects€¥nbpkgНinstall_time_nsÏ „t0¬instantiatedòinstalled_versions�£CSV§0.10.15©Downloads¦stdlibªMCMCChains¥6.0.7©StatsBase¦0.34.4¦PDMats§0.11.31Distributions¨0.25.116§PlutoUI¦0.7.60¥Plots¦1.40.9ªStatsPlots¦0.15.7²PlutoTeachingTools¥0.3.1LinearAlgebra¦stdlibªDataFrames¥1.7.0¦Turing¦0.35.5¬LaTeXStrings¥1.4.0£GLM¥1.9.0°terminal_outputsÞ £CSVÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`©DownloadsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`ªMCMCChainsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`¦PDMatsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`DistributionsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`§PlutoUIÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`ªStatsPlotsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`²PlutoTeachingToolsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`LinearAlgebraÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`¬LaTeXStringsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`©StatsBaseÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`¥PlotsÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`ªnbpkg_syncÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`ªDataFramesÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`¦TuringÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`£GLMÚ@
[0m[1mInstantiating...[22m
[90m===[39m
[0m[1mResolving...[22m
[90m===[39m
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Project.toml`
[32m[1m No Changes[22m[39m to `/tmp/jl_6itfGm/Manifest.toml`
[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m Activating[22m[39m project at `/tmp/jl_6itfGm`§enabled÷restart_recommended_msgÀ´restart_required_msgÀbusy_packages�¶waiting_for_permissionÂÙ,waiting_for_permission_but_probably_disabled«cell_inputsÞ ¡Ù$daa349a6-545b-4dfc-a3b0-92884da98e5e„§cell_idÙ$daa349a6-545b-4dfc-a3b0-92884da98e5e¤codeÚBdetails(md"""Luminosity distance from Distance modulus""",
md"""
The standard definition of the [distance modulus](https://en.wikipedia.org/wiki/Distance_modulus) is $μ = 5 \log_{10}\left(\frac{d}{\mathrm{pc}}\right) - 5$.
We'll work in megaparsecs (Mpc), so we get
$μ = 5 \log_{10}\left(\frac{d}{\mathrm{Mpc}}\right) + 25$.
Solving for $d$ gives
$d = 10^{(\mu-25)/5}$
Since we're measuring distances based on the luminosity of supernovae, we're using a [luminosity distance](https://en.wikipedia.org/wiki/Luminosity_distance) here. Hence I've included the subscript L.)
""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$556d8f17-8a03-42c8-82c7-52c8125b604d„§cell_idÙ$556d8f17-8a03-42c8-82c7-52c8125b604d¤codeÚ[begin
"""
`calc_mle_linear_model(A, y_obs, covar)`
Computes the maximum likelihood estimator for θ for the linear model
`y = A θ`
where measurements errors of `y_obs` are normally distributed with covariance matrix `covar` about the true values of `y`.
"""
function calc_mle_linear_model end
function calc_mle_linear_model(A::AbstractMatrix, y_obs::AbstractVector, covar::PDMat)
@assert size(A,1) == length(y_obs) == size(covar,1) == size(covar,2)
@assert size(A,2) >= 1
(A' * (covar \ A)) \ (A' * (covar \ y_obs) )
end
function calc_mle_linear_model(A::AbstractMatrix, y_obs::AbstractVector, covar::AbstractMatrix)
calc_mle_linear_model(A,y_obs,PDMat(covar))
end
function calc_mle_linear_model(A::AbstractMatrix, y_obs::AbstractVector, covar::AbstractVector)
calc_mle_linear_model(A,y_obs,PDiagMat(covar))
end
Docs.doc(calc_mle_linear_model)
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$77b17593-6a28-4294-9b17-41303d57d5a9„§cell_idÙ$77b17593-6a28-4294-9b17-41303d57d5a9¤codeÙjfunction loss(H::Real, data::AbstractDataFrame)
sum(abs2.((data.dₗ - data.v / H ) ./data.σ_dₗ ))
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$2482544e-ad05-495c-9787-0797939445be„§cell_idÙ$2482544e-ad05-495c-9787-0797939445be¤codeÙ›md"""
Maximum v to plot: $(@bind max_v_plt PlutoUI.Slider(max(0,ceil(minimum(df_all.v)/200)*200):200:maximum(df_all.v), default=maximum(df_all.v)/2))
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$cd4fc36e-74f1-4b33-b92c-f0b7913a7203„§cell_idÙ$cd4fc36e-74f1-4b33-b92c-f0b7913a7203¤codeÚ§details(
md"""
This data is from the [Supernovae Cosmology Project](https://supernova.lbl.gov/)'s ["Union2.1" SN Ia compilation](https://supernova.lbl.gov/Union/). Click if you're curious for more details.""",
md"""It incorporated data from 833 supernovae (SNe), drawn from 19 datasets. Of these, 580 SNe passed usability cuts. We present new data from the HST Cluster Survey.
All SNe were fit using a single lightcurve fitter (SALT2-1) and uniformly analyzed.
All analyses and cuts were developed in a blind manner, i.e. with the cosmology hidden.
The Union2.1 paper is available at [Suzuki et al. (2012)](https://ui.adsabs.harvard.edu/abs/2012ApJ...746...85S/abstract).""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0735d5d6-9328-47f7-a764-24b4b8d92ca3„§cell_idÙ$0735d5d6-9328-47f7-a764-24b4b8d92ca3¤codeÚJmd"""
The data are stored in a simple text file. There are many ways to read them. Julia has a fast reader for CSV files, so we'll demonstrate that below. For now, you don't need to pay attention to the syntax, but at some point you'll likely want to refer back to examples like this to see how to accomplish common tasks.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$beeeb261-4dcb-4093-b1cd-08682785eade„§cell_idÙ$beeeb261-4dcb-4093-b1cd-08682785eade¤codeÚ7aside(tip(md"""What does `abs2.(x)` mean?
First, `abs2(x)` would return the squared absolute value of x.
Second, when we're working with arrays rather than scalars, then we can specify element-wise arithmetic by adding a dot after a function name.
Similarly, we can add a dot before arithmetic operator (e.g., `./` instead of `/`) to specify element-wise arithmetic. (The difference is particularly important for multiplication when we need to distinguish between matrix-vector or matrix-matrix multiplication and element-wise multiplication.)
"""), v_offset=-100)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9„§cell_idÙ$da9eb594-e0fe-4e9c-be69-4150c9a44fb9¤codeÚSbegin
added_metadata
df_all = select(df_in,[:id,:z]) # select only the columns we need
# Perform variabile transofrmations informed by astrophysics
local c = speed_of_light_mps/1000 # convention is to use km/s
df_all.v = @. c-((2*c)/((df_in.z+1)^2+1)) # see equations above
df_all.dₗ = @. 10.0^((df_in.μ-25)/5) # see equations above
df_all.σ_dₗ = @. log(10) * df_all.dₗ * df_in.σ_μ/5 # propagation of uncertainty
# Now that columns have dimensions, add those as metadata
colmetadata!(df_all, :dâ‚—, "label", "velocity")
colmetadata!(df_all, :v, "units", "km/s")
colmetadata!(df_all, :dâ‚—, "label", "luminosity distance")
colmetadata!(df_all, :σ_dₗ, "label", "uncertainty in luminosity distance")
colmetadata!(df_all, :dâ‚—, "units", "Mpc")
colmetadata!(df_all, :σ_dₗ, "units", "Mpc")
df_all
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$d19e7f11-d1ff-4624-8603-38ffec0c7bea„§cell_idÙ$d19e7f11-d1ff-4624-8603-38ffec0c7bea¤code¾md"""
## Download the Data
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$c6f03d5d-18e2-4491-90fe-fe0008f774c4„§cell_idÙ$c6f03d5d-18e2-4491-90fe-fe0008f774c4¤codeÚtmd"""
A diagonal matrix containing the squared measurement uncertainties,
$\Sigma = \mathrm{diag}(\sigma_{d_{L}}^{2}) =
\begin{bmatrix}
\sigma_{d,1}^{-2} & & \\
& \sigma_{d,2}^{-2} & & \\
& & \ddots & \\
& & & \sigma_{d,N_{\mathrm{obs}}}^{-2}
\end{bmatrix},$
and the design matrix contains the velocities
$A = \left( \begin{matrix}
v_1 \\
v_2 \\
... \\
v_{N_{\mathrm{obs}}}
\end{matrix}
\right).$
In this model, we're presuming that the velocities are known exactly. While this isn't technically true, the velocities are typically measured much more precisely than the distances, so it can be a reasonable approximation.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$629dae3a-46ec-40dc-b9ed-92de9eb21adb„§cell_idÙ$629dae3a-46ec-40dc-b9ed-92de9eb21adb¤codeÙ.if ismissing(response_1e)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4518f1f7-a2a3-4783-86ae-4413fc4291b5„§cell_idÙ$4518f1f7-a2a3-4783-86ae-4413fc4291b5¤codeÙubegin
df_in = CSV.read(filename, DataFrame, delim="\t", skipto=6, header=[:id,:z,:μ,:σ_μ,:prob_low_mass_gal])
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$e4597b96-6e06-44c2-a845-3d9967d2423c„§cell_idÙ$e4597b96-6e06-44c2-a845-3d9967d2423c¤codeÙ.if ismissing(response_1i)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8„§cell_idÙ$92b2c9f6-5102-4e1a-aff1-05e9ce8c19a8¤codeÙ«md"""
After we've specified the general form of the statistcal model, we create a specific version of the model that is specialized for the valuse of the observations.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$6c86d0f1-5c6f-4204-9414-60577164f4b8„§cell_idÙ$6c86d0f1-5c6f-4204-9414-60577164f4b8¤codeÙumodel_hubble_law_lognormal_prior_given_data = model_hubble_law_lognormal_prior(df_fit.v, df_fit.dâ‚—, df_fit.σ_dâ‚—)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$a7981271-0b12-4b75-b5f0-5e91af761419„§cell_idÙ$a7981271-0b12-4b75-b5f0-5e91af761419¤codeÚœmd"""
In this case, we had a very simple model and the linear algebra was straight forward. In more complicated cases, there could be many input variables (here velocity), multiple observables being predicted (here distance), correlations between the different observables, and many possible models to try. Setting up all the matrices and getting all the algebra right for each model is error prone. Therefore, most modern high-level programming languages have packages that make it easy to fit linear models such as this one. Below, we'll repeat the analysis, but using Julia's [GLM.jl](https://juliastats.org/GLM.jl/stable/) package for general linear models."""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$276a850b-09da-41f0-8661-5d63bb2afdf8„§cell_idÙ$276a850b-09da-41f0-8661-5d63bb2afdf8¤codeÙ¿if ready_to_run_mcmc
chain_uniform_prior = sample(model_hubble_law_uniform_prior_given_data, NUTS(0.65), MCMCThreads(), num_mcmc_samples, num_chains)
else
chain_uniform_prior = nothing
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974b„§cell_idÙ$bd560d5d-3bc7-4b4d-aab7-67b1884a974b¤codeÙÓbegin
scatter(Hâ‚€s_plt, loss_vs_Hâ‚€_all, markercolor=:blue, label=:none)
plot!(Hâ‚€s_plt, loss_vs_Hâ‚€_all, linecolor=:blue, label=:none)
xlabel!("Hâ‚€ (km/s/Mpc)")
ylabel!("loss = χ²(H₀)")
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$0236d055-0d6d-440d-a44b-0d5cb0ab2273„§cell_idÙ$0236d055-0d6d-440d-a44b-0d5cb0ab2273¤codeµresponse_2b = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$efde0b1e-ec47-4180-aba7-ed8843395b50„§cell_idÙ$efde0b1e-ec47-4180-aba7-ed8843395b50¤codeÙ‚md"""**Q1c:** Use the slider below to try different values of $H_0$. Approximately what value looks like the best-fit to you?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$48e246bc-4937-40d6-b686-73524f3ce057„§cell_idÙ$48e246bc-4937-40d6-b686-73524f3ce057¤codeÙ*# hideall
md"""
# Setup & Helper Code
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2786b37a-207f-4831-983e-81a380c37045„§cell_idÙ$2786b37a-207f-4831-983e-81a380c37045¤codeÚomd"""
If one puts in a fair bit of algebra, then one can find an analytical expression for the value of the model parameters ($\theta$) that minimizes the likelihood for a linear model.
You're likely to see the derivation of the solution in class on staistics (or maybe linear algebra), but we'll just use the result:
$\hat{\theta} = (A' \Sigma^{-1} A)^{-1} (A' \Sigma^{-1} \ y_\mathrm{obs} ),$
where $y_{\mathrm{obs}}$ is the vector of measurement values, $\Sigma^{-1}$ is the covariance matrix, and $A$ is the **[design matrix](https://en.wikipedia.org/wiki/Design_matrix)**.
For our problem, these simplify to:
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70e„§cell_idÙ$0d0917aa-674e-47c4-a8dc-4d1585ebb70e¤codeÙÍbegin
# Specify a range of values to try
Hâ‚€s_plt = range(40, stop=100, step=2)
# Apply loss function for each value in the range
loss_vs_Hâ‚€_all = map(Hâ‚€->loss(Hâ‚€,df_all),Hâ‚€s_plt)
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$d3e82a29-c1b5-4f5a-ba96-a64d22636493„§cell_idÙ$d3e82a29-c1b5-4f5a-ba96-a64d22636493¤codeÙímd"""
Notice that this code is very different from a tradditional program where we'd specify how to compute each variable in order (known as the [imperative programming](https://en.wikipedia.org/wiki/Imperative_programming) model).
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$49090825-2843-4b3e-8ee6-658187232f96„§cell_idÙ$49090825-2843-4b3e-8ee6-658187232f96¤codeÙ,md"""
## Sensitivity to Choice of Priors
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$e0e610d7-a237-42ea-8706-8e09858fba03„§cell_idÙ$e0e610d7-a237-42ea-8706-8e09858fba03¤codeÙ.if ismissing(response_2e)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0a„§cell_idÙ$ce45a056-a949-4a9c-850e-9b5a997ecb0a¤codeÚ|if !ismissing(response_1f)
let
Hâ‚€s_plt_zoom = range(50, stop=75, step=0.5)
# Apply loss function for each value in the range
loss_vs_Hâ‚€_all = map(Hâ‚€->loss(Hâ‚€,df_all),Hâ‚€s_plt_zoom)
# Plot χ² surface for all data in blue
loss_Hâ‚€_bf_all = loss(Hâ‚€_bf_all,df_all)
dof_all = size(df_all,1)-1
plt = plot(xlabel = "H₀ (km/s/Mpc)",ylabel = "Δχ²", legend=:topleft)
ylims!(0,size(df_all,1)*0.4)
scatter!(plt, Hâ‚€s_plt_zoom, loss_vs_Hâ‚€_all .- loss_Hâ‚€_bf_all, markercolor=:blue, label=:none)
plot!(plt, Hâ‚€s_plt_zoom, loss_vs_Hâ‚€_all .- loss_Hâ‚€_bf_all, linecolor=:blue, label=:none)
plot!(plt,fill(Hâ‚€_wls_all,2), [0, 1000], linecolor=:blue, label="Best-fit for All" )
plot!(plt,[H₀_wls_all-σ_H₀_all,H₀_wls_all+σ_H₀_all], fill(100,2), linecolor=:blue, lw=3, label=:none )
# Plot χ² surface for selected data in red
loss_vs_Hâ‚€ = map(Hâ‚€->loss(Hâ‚€,df_fit),Hâ‚€s_plt_zoom)
loss_Hâ‚€_bf_fit = loss(Hâ‚€_wls_fit,df_fit)
dof_fit = size(df_fit,1)-1
scatter!(plt, Hâ‚€s_plt_zoom, loss_vs_Hâ‚€ .- loss_Hâ‚€_bf_fit, markercolor=:red, label=:none)
plot!(plt, Hâ‚€s_plt_zoom, loss_vs_Hâ‚€ .- loss_Hâ‚€_bf_fit, linecolor=:red, label=:none)
plot!(plt,fill(Hâ‚€_wls_fit,2), [0, 1000], linecolor=:red, label="Best-fit for Subset" )
plot!(plt,[H₀_wls_fit-σ_H₀_fit,H₀_wls_fit+σ_H₀_fit], fill(100,2), linecolor=:red, lw=3, label=:none )
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$1d70572f-214e-4161-b804-2c3b7c077c56„§cell_idÙ$1d70572f-214e-4161-b804-2c3b7c077c56¤codeÙŽbegin
σ_H₀inv_all = calc_sigma_mle_linear_model(A_all, Σ_all)[1]
σ_H₀_all = abs(H₀_bf_all * σ_H₀inv_all / H₀inv_bf_all[1])
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$23ee2544-2a2f-4302-8a62-2dd868cbb5d1„§cell_idÙ$23ee2544-2a2f-4302-8a62-2dd868cbb5d1¤codeµresponse_2d = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$69ca76b8-8766-47fe-89d6-31fcc7a60e88„§cell_idÙ$69ca76b8-8766-47fe-89d6-31fcc7a60e88¤code¹response_1f = 0 # missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$18106638-c96c-47d6-990d-b35b6b0ba218„§cell_idÙ$18106638-c96c-47d6-990d-b35b6b0ba218¤codeÙ}md"""
Select type of plot to show: $(@bind histogram_or_density Select([histogram => "histogram", density => "density"]))
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$f90594d8-92a1-4b0b-93d0-0e41e76b3f55„§cell_idÙ$f90594d8-92a1-4b0b-93d0-0e41e76b3f55¤codeÚmd"""**Q1e:** How does the best-fit value computed above compare to your previous estimate based on the plot of $\chi^2$ vs $H_0$? What is likely to explain any differences?
Does Hubble's law provide a good model for these observations? If not, explain your concern."""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$aaa80da1-f7de-42ed-9691-c367e6bd9a28„§cell_idÙ$aaa80da1-f7de-42ed-9691-c367e6bd9a28¤code»# hideall
TableOfContents()¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18„§cell_idÙ$0adf35a1-d7a8-4e7b-ad3f-ac83bd44ef18¤codeÙ.if ismissing(response_1f)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$92ca099c-b81b-4cfe-a3fa-60833657f4ef„§cell_idÙ$92ca099c-b81b-4cfe-a3fa-60833657f4ef¤codeÚRmd"""The Hubble "law" ($v = H_0 \times d$) for the expansion of the universe is based on velocity versus distance. That's not what this data file provided, but we can compute those using standard expressions that you may have seen in an introduction to astronomy class. You learn or refresh your memory about each by clicking below."""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$03fc47ea-9246-4cb8-8398-612fc2fb09fa„§cell_idÙ$03fc47ea-9246-4cb8-8398-612fc2fb09fa¤codeµresponse_1b = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48„§cell_idÙ$d3db2bc4-a26b-4e01-a193-b155a92dab48¤codeÚÝ@model function model_hubble_law_lognormal_prior(v, d_obs, σ_d_obs)
# Verify that size of each data vector matches
@assert size(v) == size(d_obs) == size(σ_d_obs)
# Specify priors for model parameters
Hâ‚€ ~ LogNormal(log(100), 1.0)
# Specify how to compute the model's predictions given parameter values
d_true = v / Hâ‚€
# Specify distribution for observations given the true values and measurement uncertainties
d_obs ~ MvNormal(d_true, σ_d_obs)
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$9db3ff24-6f54-4a37-b787-de4b14694d95„§cell_idÙ$9db3ff24-6f54-4a37-b787-de4b14694d95¤codeÚë"""
`calc_fisher_matrix_linear_model(A, covar)`
Computes the Fisher information matrix for θ for the linear model
`y = A θ`
where measurements errors of `y_obs` are normally distributed and have covariance `covar`.
Note that `y_obs` is not passed to this function, because it does not affect results.
"""
function calc_fisher_matrix_linear_model(A::AbstractMatrix, covar::AbstractMatrix)
@assert size(A,1) == size(covar,1) == size(covar,2)
@assert size(A,2) >= 1
(A' * (covar \ A))
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$c6af6d4a-ff58-4012-b4b2-4e3b09d53638„§cell_idÙ$c6af6d4a-ff58-4012-b4b2-4e3b09d53638¤codeÙ.if ismissing(response_1h)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572„§cell_idÙ$0c0312da-558a-4bc1-9e4a-b02ecd1c0572¤codeÙ.if ismissing(response_1b)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$b15b1913-d265-4a35-b43e-67df53c93329„§cell_idÙ$b15b1913-d265-4a35-b43e-67df53c93329¤codeÙ¤details("How to access metadata",
md"""
You can access the metadata from a `DataFrame` using function calls like `metadata(df_in)` or `colmetadata(df_in,:z)`.
""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4655178c-a633-4b50-8f92-6ee028e21d0e„§cell_idÙ$4655178c-a633-4b50-8f92-6ee028e21d0e¤codeÙ,md"""
## Apply Variable Transformations
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3bdb27da-451c-4260-bf43-5568985d24f2„§cell_idÙ$3bdb27da-451c-4260-bf43-5568985d24f2¤codeÚ md"""
As we develop more complex models, it will often not be practical to find the maximum likelihood estimator values analyticly or using a general linear modeling package.
Or there may be significant prior knowledge that we'd like to incorporate into our analysis.
Or we might want to perform a more rigorous analysis of the uncertainties on the model parameters.
In any of these cases, it can be very useful to use a probabilistic modeling language (PPL), such as [Turing](https://turinglang.org/) or [Stan](https://mc-stan.org/).
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2f7c11e8-d429-41eb-873e-ae554e028195„§cell_idÙ$2f7c11e8-d429-41eb-873e-ae554e028195¤codeÙ{md"""**Q1a:** Is this plot consistent with your expectations for velocity versus distance? If not, what surprised you?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$8764ccfe-81cd-4bff-985a-c112fc5c902f„§cell_idÙ$8764ccfe-81cd-4bff-985a-c112fc5c902f¤codeÚmd"""**Q2a:** How do the mean and standard deviation for the Hubble constant estimated with our Bayesian model and Turing compare to the analytic estimates using linear model (and the same dataset)? Are any differences large or small compare to the reported uncertainties?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$b7e2903b-be56-4e36-885f-e16a9ddc94c6„§cell_idÙ$b7e2903b-be56-4e36-885f-e16a9ddc94c6¤codeÚzmd"""
This value is nothing like what we got above. Why? Remember that to write this in a form ammenable to the analytic solution, we predicted distances based on velocities $d = v / H_0$, so the best-fit constant of proportionality is the recipocal of $H_0$. Let's transform that back to a best-fit value for the Hubble constant, $\hat{H_0}_{,bf} = 1/\hat{\theta}_{bf}$.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264„§cell_idÙ$4eb123a1-f976-4fad-9a96-e3a61bdbf264¤codeµresponse_2a = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$089c50b6-5494-4f27-af3e-a8af972e2869„§cell_idÙ$089c50b6-5494-4f27-af3e-a8af972e2869¤codeµresponse_2c = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709„§cell_idÙ$34ccd3d7-e914-4f6f-a8eb-f421ed17e709¤codeÚÖmd"""
You likely noticed that Hubble's "Law" wasn't a great model for this dataset.
That's because it's an incomplete model that works well in the local universe, but breaks down once astronomers look far enough away that we can see the effects of dark energy causing the rate of expansion to accelerate.
If we want to measure the local Hubble constant, then we could fit a subset of our dataset, picking those SN that have velocities less than some threshold.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6„§cell_idÙ$e02dd163-59bc-4d48-ae43-6fc559536aa6¤codeÚ™md"""
For the above model, then likelihood is given by
$\mathcal{L} = \frac{1}{\sqrt{(2\pi)^{N_{\mathrm{obs}}} \prod_{i=1}^{N_{\mathrm{obs}}} \sigma_{d,i}^2} } \; e^{-\chi^2/2}$
Minimizing $\mathcal{L}$ is equivalent to minimizing $\ell = \log(\mathcal{L})$.
Since the first factor doesn't depend on the measured values of distance, we can minimize $\mathcal{L}$ and $\ell$ by minimizing $\chi^2$.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$a56871c9-affa-4612-b3f5-66363720f274„§cell_idÙ$a56871c9-affa-4612-b3f5-66363720f274¤codeÙ5md"""
and we can compute some summary statistics.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4f27d8d1-0d14-49e5-abee-9f277369a78b„§cell_idÙ$4f27d8d1-0d14-49e5-abee-9f277369a78b¤codeÚý@model function model_hubble_law_uniform_prior(v, d_obs, σ_d_obs)
# Verify that size of each data vector matches
@assert size(v) == size(d_obs) == size(σ_d_obs)
# Specify priors for model parameters
Hâ‚€ ~ Uniform(-speed_of_light_mps/1000, speed_of_light_mps/1000)
# Specify how to compute the model's predictions given parameter values
d_true = v / Hâ‚€
# Specify distribution for observations given the true values and measurement uncertainties
d_obs ~ MvNormal(d_true, σ_d_obs)
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$0144843f-b649-4ea2-a546-e8c14a928670„§cell_idÙ$0144843f-b649-4ea2-a546-e8c14a928670¤codeÚ2md"""**Q2b:** How do the estimates of the posterior mean and standard deviation using two different choices for the prior compare to each other?
Are any differences large or small compare to the reported uncertainties? What does this imply about the sensitivity of our analysis to the choice of prior?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$a7d8f517-4117-4585-8089-117510c944c5„§cell_idÙ$a7d8f517-4117-4585-8089-117510c944c5¤codeÙ!speed_of_light_mps = 299_792_458;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$18dd7cac-fac3-4c40-9230-f6387e41751b„§cell_idÙ$18dd7cac-fac3-4c40-9230-f6387e41751b¤codeÙ¾md"""**Q1b:** Do you notice anything potentially concerning about the plot? If so, describe your concerns. Optionally, use the cell below to perform any tests to address your concerns."""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$fa745b36-7465-443e-9f50-c786fe418c6a„§cell_idÙ$fa745b36-7465-443e-9f50-c786fe418c6a¤codeÙ$Σ_all = PDiagMat(df_all.σ_dâ‚—.^2)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82„§cell_idÙ$b4a68a89-bd1f-49d5-adb2-6239317a8b82¤codeÙMwls_all = lm(formula_wo_intercept, df_all, wts=weights(df_all.σ_dâ‚—.^(-2)))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6„§cell_idÙ$a8d72fee-302c-44f6-8ca3-9e0b1a130ec6¤codeÚ˜details("Probabilistic Programming Languages",
md"""
Traditionally, programmers provide explicit instructions for what steps the program should perform in what order (known as the [imperative programming](https://en.wikipedia.org/wiki/Imperative_programming) model).
But there are alternatives.
For example, [probabilistic programming languages](https://en.wikipedia.org/wiki/Probabilistic_programming) (PPLs) allow programmers to specify target probability distributions to be computed (or sampled from), without specifying how to perform inference with that target distribution.
In this exercise, we'll demonstrate how to use the [Turing.jl](https://turinglang.org/) PPL.
Turing is implemented entirely in Julia and is highly composable, so that one can perform inference with complex models written in Julia.
In this notebook, we'll demonstrate applying it to the simple model for the Hubble expansion.
""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$c433e938-31f7-4417-b3c0-a2f49fea8640„§cell_idÙ$c433e938-31f7-4417-b3c0-a2f49fea8640¤codeÙqmd"""
Check once you're ready to run the Bayesian models: $(@bind ready_to_run_mcmc CheckBox(; default=true))
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3aba1134-7c60-41f6-a1ac-73306efb7824„§cell_idÙ$3aba1134-7c60-41f6-a1ac-73306efb7824¤codeÚÊmd"""
## Goodness-of-fit statistic
Usually, we don't know the true value of all our model's parameters (in this case the Hubble constant).
Therefore, we want to use astronomical data to measure (or more generally to improve our knowldge of) the model parameters.
For any value of the model parameter(s), we can compute the residuals between the observations and the model predicitons, $\Delta_i = d_i - v_{\mathrm{obs},i}/H_0$.
**If** the model and model parameters were the perfect truth, then
$\Delta_i \sim \mathrm{Normal}(0,\sigma_i^2).$
Even if the model isn't perfect, we can compute a goodness-of-fit [statistic](https://en.wikipedia.org/wiki/Statistic),
$\chi^2 = \sum_{i=1}^{N_\mathrm{obs}} \Delta_i^2.$
If the model is perfect, then
$\chi^2 = \sum_{i=1}^{N_\mathrm{obs}} \Delta_i^2/\sigma_i^2$
and its expected value becomes
$E\left[\sum_{i=1}^{N_\mathrm{obs}} \Delta_i^2/\sigma_i^2 \right] = N_{\mathrm{obs}},$
since $E[\Delta_i^2/\sigma_i^2] = 1$ for each $i$.
If we evaluate $\chi^2$ using model parameters that differ from the truth, then the expected value of the value of $\chi^2$ statistic increases.
We can find the value of the model parameters than minimize $\chi^2$ to provide us with the **best-fit** model.
This model for observations is so common that statistican have given a name to the probabilitiy distribution that the $\chi^2$ statistic follows... the [$\chi^2$ distribution](https://en.wikipedia.org/wiki/Chi-squared_distribution).
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$5e635a20-e205-48f0-908d-cb6d0c55b43b„§cell_idÙ$5e635a20-e205-48f0-908d-cb6d0c55b43b¤codeÙ2md"""
# Bayesian Inference with a Linear Model
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8„§cell_idÙ$4dff84e9-3ca6-4ffb-893b-ef7ec03939b8¤codeÚLif !ismissing(response_1f)
A_fit = reshape(df_fit.v, size(df_fit,1), 1);
Σ_fit = PDiagMat(df_fit.σ_dₗ.^2);
H₀inv_fit = calc_mle_linear_model(A_fit, df_fit.dₗ, Σ_fit)[1]
σ_H₀inv_fit = calc_sigma_mle_linear_model(A_fit, Σ_fit)[1]
Hâ‚€_fit = 1/Hâ‚€inv_fit
σ_H₀_fit = abs(H₀_fit * σ_H₀inv_fit/H₀inv_fit)
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$7be54420-b2ec-4ef4-adc8-848817305d07„§cell_idÙ$7be54420-b2ec-4ef4-adc8-848817305d07¤codeÙ&md"""
# Injests & Prepare the Data
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$16b0a2c1-5803-4310-9ee7-884b1333fb74„§cell_idÙ$16b0a2c1-5803-4310-9ee7-884b1333fb74¤codeÙÂmd"""**Q1h:** Which dataset do you think provides a better estimate of the Hubble constant? Why?
For which dataset is the formal measurement uncertainty larger? Explain your why that is."""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0c20b9a7-69a9-49c8-9ba4-45b8770393d0„§cell_idÙ$0c20b9a7-69a9-49c8-9ba4-45b8770393d0¤codeÚ(md"""
Use the slider below to pick a threshold velocity below which the model of a linear releationship between $v$ and $d$ appears to be accurate. The figure will automatically update to show only the data you've selected and the predictions with the best-fit $H_0$ for that subset of data.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9„§cell_idÙ$56d8e6c4-1f19-4bb4-a3db-7bf00675efd9¤codeÙÝ# hideall
begin
using Downloads
using CSV, DataFrames
using Plots, LaTeXStrings
using StatsBase, GLM, PDMats, LinearAlgebra
using Distributions, Turing, MCMCChains, StatsPlots
using PlutoUI, PlutoTeachingTools
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$d70d95e9-f0e7-4225-8e06-80735278cbca„§cell_idÙ$d70d95e9-f0e7-4225-8e06-80735278cbca¤codeÙÃmd"""
Hâ‚€ to plot: $(@bind Hâ‚€_plt_1 PlutoUI.Slider(10:100.0, default=65.0))
Show uncertainties: $(@bind plt_yerr PlutoUI.CheckBox())
Show residuals: $(@bind plt_resid PlutoUI.CheckBox())
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5b„§cell_idÙ$9f4d8983-d2d7-4bc9-bb31-5460a18dac5b¤codeÙdetails(md"Velocity from redshift",md"By definition $1+z = \sqrt{\frac{c+v}{c-v}},$ where $c$ is the speed of light. Solving for $v$ gives $v = c - \frac{2c}{(1+z)^2+1}$.")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$22da4ae4-6aea-4d45-ab2c-6fe935783e41„§cell_idÙ$22da4ae4-6aea-4d45-ab2c-6fe935783e41¤codeµresponse_1h = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$a8f89fe8-110b-452e-9ecb-53769aa02a2e„§cell_idÙ$a8f89fe8-110b-452e-9ecb-53769aa02a2e¤codeÚ{md"""
#### Overview
In this lab, we'll measure the Hubble constant ($H_0$), the rate of expansion of the local universe using observations of Type 1a Supernovae.
First, we'll download and read data from the Supernovae Cosmology Project and do a few transformations, so that we can plot velocity versus distance.
Second, we'll develop a statistical model to describe our data based on our understanding of the astrophysics and measurement process.
We'll compute the maximum likelihood estimate for the model parameters using conventional linear algebra techniques. This is a *very* useful and common method.
(I'd say its analogous the harmonic oscillator in physics!)
Next, we'll preview multiple other ways we could have fit the same model, but using different techniques.
You'll think about some of the results as we go and the advantages/disadvantages/limitations of each approach.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$a01c7aad-429d-447b-8943-a4e89dbac6f6„§cell_idÙ$a01c7aad-429d-447b-8943-a4e89dbac6f6¤codeÙ.if ismissing(response_2d)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3„§cell_idÙ$cf6fbe84-9a51-4ddb-9def-c22893a17ed3¤codeÙÆif ready_to_run_mcmc
chain_lognormal_prior = sample(model_hubble_law_lognormal_prior_given_data, NUTS(0.65), MCMCThreads(), num_mcmc_samples, num_chains)
else
chain_lognormal_prior = nothing
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$098afd51-2c39-42ef-91bf-cfc326827ea1„§cell_idÙ$098afd51-2c39-42ef-91bf-cfc326827ea1¤codeÙÑmd"""**Q1d:** Based on the figure above, what would you estiamte for the best-fit value of $H_0$? How did your previous estimate of the best-fit value for $H_0$ compare to the minimum in the figure above?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bc„§cell_idÙ$d95d2e2d-c6ff-4cab-8b49-432ef61065bc¤codeÙ}let
plt = plot_hubble_diagram(df_all,Hâ‚€_bf_all, show_yerr=true)
title!(plt,"Best-fit Hubble constant for full dataset")
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479„§cell_idÙ$a1b5939b-b1ed-4d7c-907d-5bf3e7dd4479¤codeÙlmd"""
Now we can easily compute & plot the $\chi^2$ as a function of the value of the Hubble parameter.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56d„§cell_idÙ$78eb6aff-3752-41d8-a4d9-0cc2b31fd56d¤codeÙ:md"""
## Quantifying Uncertainties in Model Parameters
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4„§cell_idÙ$ac47f631-787d-4a3c-96cf-5fee86a3b2f4¤codeÙ"Hâ‚€_ols_all = 1 /coef(ols_all)[1]¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$42366f09-d437-4ba2-93ec-f7b8278eb09d„§cell_idÙ$42366f09-d437-4ba2-93ec-f7b8278eb09d¤codeÙÔmd"""**Q1i:** Is the difference between the best-fit values for the two datasets larger or smaller than the formal uncertainty estimates? What does that imply for the true uncertainty in the Hubble constant?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d0f003fa-f72d-4a6f-ba60-1cad3844ef6a„§cell_idÙ$d0f003fa-f72d-4a6f-ba60-1cad3844ef6a¤codeÚªmd"""
In the function `model_hubble_law_uniform_prior`, we specified the probability distribution for each random variable using the syntax `variable ~ distribution`.
For example, we specified the prior for $H_0$ and the likelihood, $\mathcal{L} = p(d_{\mathrm{obs}} | d_{\mathrm{true}}, σ_d)$.
We specify how the true distance can be computed from the velocity and Hubble constant, but we .
The input arguements for the model are the data to be analyzed, including $d_\mathrm{obs}$.
But we won't specify a value for $H_0$ or the values of $d_\mathrm{true}$.
The computer will figure out the distributions implied for both of these variables given the data we provide.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$f0220da0-6f3a-438c-b533-acb346382418„§cell_idÙ$f0220da0-6f3a-438c-b533-acb346382418¤codeÚµdetails(md"Ready for an explanation of the syntax above?",
md"""
Before we can use Julia's CSV reader, first we need to load the [CSV.jl](https://csv.juliadata.org/stable/) package. That's done at the bottom of the notebook with the command `using CSV`. Then we can call the function `CSV.read(...)`.
The first two function arguements specify the filename and that we should read the data into a `DataFrame`.
The remaining arguements are option and allow us to fine-tune the behavior of the CSV reader.
This data file used tabs (written using the escaple code `\t`) to separate the columns rather than the standard commas, so we had to specify that with the optional `delim` parameter.
Additionally, the file included some comments/metadata in the first five rows, so we had to tell the CSV reader to skip to row 6 using the optional `skipto` parameter.
Finally, the file didn't include column heading, so we provided those manually.
""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$8bfe0413-782b-4244-8624-a9f95e393d17„§cell_idÙ$8bfe0413-782b-4244-8624-a9f95e393d17¤codeÚmd"""
Packages like `GLM.jl` allow us to specify a model with a *modeling language*. The compiler figures out how to build the matrices and what calculations to peform in order to compute the MLEs. The simplest possible model formula is `d ~ v` meaning the distance is proportional to velocity (the constant to be fit is implicit). We then call the `lm` function to return the best fit model for a given model and dataset.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3ec3e49c-04ce-4ffa-b1ca-8c58df0307dd„§cell_idÙ$3ec3e49c-04ce-4ffa-b1ca-8c58df0307dd¤codeÚmd"""
In the figure above, the vertical line indicates the best-fit value for each dataset and the the horizontal bar shows the the measurement uncertainty for each dataset.
We could estimate the uncertainties by calculating the second derivative of the log likelihood.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$92238689-d9df-46c2-bd72-3fcc41a22594„§cell_idÙ$92238689-d9df-46c2-bd72-3fcc41a22594¤codeÚ�md"""
The output table provides the best-fit value for each of the parameters in the linear model. In this case there is the the coefficient to v ($1/H_0$) as well as an intercept. That's because it fit the model $d = c_v v + c_{\mathrm{intercept}}$, rather than just $d = c_v v$. We can tell it that we don't want to include an intercept using the model formula `dâ‚— ~ 0 + v`.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d5c3923b-8515-4002-9d93-6768f087aef6„§cell_idÙ$d5c3923b-8515-4002-9d93-6768f087aef6¤codeÚ7md"""**Q2c:** Given your findings above, which of the following choices is likely to have the most significant effect on your measurement of the Hubble constant?
- Choice of supernovae to be included in analysis
- Choice of whether to estimate $H_0$ with an MLE or MAP estimator
- Choice of prior for $H_0$
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4f11d0e2-7126-47f1-865a-3474298597dc„§cell_idÙ$4f11d0e2-7126-47f1-865a-3474298597dc¤codeÚ³md"""
When using a PPL like Turing, we need to specify a prior distribution for each model parameter and the likelihood function describing how the observations are generated from the model. For example, we could adopt a Normal prior for $H_0$:
$H_0 \sim \mathrm{Normal}(0,\sigma_{pr,H_0}^2)$
and a Normal likelihood for each observation
$d_{\mathrm{obs},i} \sim \mathrm{Normal}(d_{\mathrm{true},i},\sigma_{d,i}^2) \; \; ∀ \; i ∈ 1... N_{\mathrm{obs}}$
where
$d_{\mathrm{true},i} = v_i / H_0.$
It's often helpful to use vector notation, $\bf{d_{\mathrm{obs}}} \sim \mathrm{MvNormal}(\bf{d_{\mathrm{true}}},\bf{\sigma_{d}}^2).$
We implement this model using the following code
"""
¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$337a560b-49f3-4fc5-926f-1689911eacf2„§cell_idÙ$337a560b-49f3-4fc5-926f-1689911eacf2¤codeÙ«md"""**Q2d:** Can you think of another improvement we could make to improve the quality of inferences about the expansion rate of the universe? Explain your thinking."""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6„§cell_idÙ$7b5b3e8a-61ac-43cf-8b85-4a8a8e4846f6¤codeÚmd"""
One nice feature of using a PPL like Turing is that they make it easy to repeat analyses using slightly different assumptions. For example, we could switch to using a [LogNormal](https://en.wikipedia.org/wiki/Normal_distribution) prior distribution for $H_0$.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d81347d3-9246-42d9-9a85-42c773ef2a1d„§cell_idÙ$d81347d3-9246-42d9-9a85-42c773ef2a1d¤codeÚbegin
metadata!(df_in,"source", url, style =:note)
colmetadata!(df_in, :z, "label", "redshift", style =:note)
colmetadata!(df_in, :μ, "label", "distance modulus")
colmetadata!(df_in, :σ_μ, "label", "uncertainty in distance modulus")
added_metadata = true
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$adf117fe-0f54-4f2a-b107-0635f56263f2„§cell_idÙ$adf117fe-0f54-4f2a-b107-0635f56263f2¤codeµresponse_2e = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$2ad2563a-8a72-47e8-a36d-f6d2a49cb517„§cell_idÙ$2ad2563a-8a72-47e8-a36d-f6d2a49cb517¤codeÙ}if chain_uniform_prior!=nothing
(Hâ‚€_posterior_mean, Hâ‚€_posterior_std) = mean_and_std(vec(chain_uniform_prior[:Hâ‚€]))
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$c086c05f-ad73-44c7-bf8b-a304d3533690„§cell_idÙ$c086c05f-ad73-44c7-bf8b-a304d3533690¤codeÚ&"""
`calc_sigma_mle_linear_model(A, covar)`
Computes the uncertainty in the maximum likelihood estimate of θ for the linear model
`y = A θ`
where measurements errors of `y_obs` are normally distributed and have covariance `covar`.
Note that `y_obs` is not passed to this function, because it does not affect results.
"""
function calc_sigma_mle_linear_model(A::AbstractMatrix, covar::AbstractMatrix)
@assert size(A,1) == size(covar,1) == size(covar,2)
@assert size(A,2) >= 1
sqrt.(diag(inv(PDMat(calc_fisher_matrix_linear_model(A,covar)))))
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0a4aaa8a-20da-486f-ace5-fbadcf646609„§cell_idÙ$0a4aaa8a-20da-486f-ace5-fbadcf646609¤codeÙCif chain_uniform_prior!=nothing
describe(chain_uniform_prior)
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$eb72dda6-69f0-4538-a75a-25967653759f„§cell_idÙ$eb72dda6-69f0-4538-a75a-25967653759f¤codeÙ_md"""
Now we can compare the estimates of the posterior PDF under the two different models.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2d97268e-560b-4398-982e-1cf5cd9ab7dd„§cell_idÙ$2d97268e-560b-4398-982e-1cf5cd9ab7dd¤codeÙ.if ismissing(response_2b)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$28b844a8-650a-47d8-b9f6-586f22d6f603„§cell_idÙ$28b844a8-650a-47d8-b9f6-586f22d6f603¤codeÚßmd"""
Hmm... This value is significantly different that what we found above. Why?
In the calls above, we used the method of **[Ordinary Least Squares](https://en.wikipedia.org/wiki/Ordinary_least_squares)** which ignores the measurement uncertainties and weights each point equally. We can instead request it use the method of **[Weighted Least Squares](https://en.wikipedia.org/wiki/Weighted_least_squares)** and tell it to use inverse variance weighting as shown below.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$c78f0ad9-03c0-4066-a390-193e7bfa84b1„§cell_idÙ$c78f0ad9-03c0-4066-a390-193e7bfa84b1¤codeÙ½md"""**Q2e:** How could using a probabilistic programming language like Turing make it relatively easy to improve the quality of our inferences about the expansion rate of our universe?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$1c35257a-9b98-4af6-bde0-a945665c91cd„§cell_idÙ$1c35257a-9b98-4af6-bde0-a945665c91cd¤codeÚbdetails(md"""Propagation of uncertainties""",
md"""The data file provide measurement uncertainties for the distance modulus. We'd like measurement uncertainties for the distance. Unders several assumptions (e.g., small magnitude of uncertainties, uncorrelated uncertainties), we can estimate the measurement uncertainty in the distance by applying the [Propagation of uncertainties](https://en.wikipedia.org/wiki/Propagation_of_uncertainty) method. If you haven't seen this before, then I'd suggest that you just trust me on this for now rather than worrying about the derivation of the equation used.
""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6„§cell_idÙ$751eff6b-2ed2-4073-b8b5-02ad9981edb6¤codeµresponse_1i = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7db„§cell_idÙ$5974dfc3-8416-4bae-91de-d3f0a4f0c7db¤codeÙ.if ismissing(response_1a)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$20f739ff-cc5b-460e-851a-141003d0c9d0„§cell_idÙ$20f739ff-cc5b-460e-851a-141003d0c9d0¤codeÙSmd"""
Now the value returned should match our previous analysis very closely.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$f76f4c3c-74f1-44b0-9b3a-5895aec22e70„§cell_idÙ$f76f4c3c-74f1-44b0-9b3a-5895aec22e70¤codeÙ!Hâ‚€_bf_all = 1/Hâ‚€inv_bf_all[1]¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$a98ace81-9afd-4618-88a6-fadaf04eb364„§cell_idÙ$a98ace81-9afd-4618-88a6-fadaf04eb364¤codeÙ.if ismissing(response_1d)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1„§cell_idÙ$bd1c72d5-1d0d-4e36-aba4-95c9c9e4fab1¤codeµresponse_1e = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$95bc4b33-d619-4a95-af19-5771d209336d„§cell_idÙ$95bc4b33-d619-4a95-af19-5771d209336d¤codeÙk# hideall
begin
title = "Astro 416: Lab 3, Ex 1"
week = 3
topic = "Model Building I: Linear Models"
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0„§cell_idÙ$4bdd7b2d-9a67-4161-a0a0-93073d9edcf0¤codeÙ—md"""
### Plot the data
It's often a good idea to make a quick plot to help validate our dataset and to understand the characteristics of the data.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2532e9de-8fa7-44ce-8502-c2473928aa8e„§cell_idÙ$2532e9de-8fa7-44ce-8502-c2473928aa8e¤code¯WidthOverDocs()¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4a2c109d-8e18-4561-913b-769f7eaeb6e9„§cell_idÙ$4a2c109d-8e18-4561-913b-769f7eaeb6e9¤codeÚçmd"""
# Develop a model
In this case, it may be tempting to rush to fitting a line to the data.
But we want to use this example as a chance to think through the process of building models.
It's often useful to divide the full model for astronomical observations into two parts: a physical model and a measurement model.
### Physical model
In this case, our initial physical model is that the local universe is expanding away from us at a velocity ($v$) proportion to the distance ($d$).
The rate of proportionality is known as the Hubble constant ($H_0$).
If this model were perfectly accurate and there were no measurement errors, then we'd have
$$d = H_0^{-1} v.$$
### Measurement model
Astronomical measurements almost always have some measurement errors.
It can be useful to be explicit about when we're referring to the true value and when we're referring to the observed value.
For example, if we were measuring $v$, then we might write:
$d_{\rm obs} = d_{\rm true} + \epsilon,$
where $\epsilon$ is the measurement error.
By definition the true value of the measurement error ($\epsilon$) is almost always unknown.
Typically, astronomers design the measurements such that the expected value of the measurement is equal the true value ($E[d_{\rm obs}] = d_{\rm true}$),
and characterize the distribution of the measurement errors.
One very common model/approximation is that the measurement errors follow a [Normal (or Gaussian) distribution](https://en.wikipedia.org/wiki/Normal_distribution) with a scale parameter, $\sigma$.
We denote that with
$\epsilon \sim \mathrm{Normal}(0,\sigma^2).$
Based on the properties of the Normal distribution,
$E[\epsilon]=0$, and
$E[\epsilon^2] = \sigma^2$.
For this lab, we'll assume that's a good approximation here.
When we have many measurements, we could write the errors explicitly like
$d_{i,\rm obs} = d_{i,\rm true} + \epsilon_i = v_i/H_0 + \epsilon_i,$
where $\epsilon_i \sim \mathrm{Normal}(0,\sigma_i^2)$ for each obsevation $i\in 1...N_{\mathrm obs}$
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2f3d492c-4a5e-4a56-a773-e8078e14476a„§cell_idÙ$2f3d492c-4a5e-4a56-a773-e8078e14476a¤codeÙBHâ‚€inv_bf_all = calc_mle_linear_model(A_all, df_all.dâ‚—, Σ_all)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$c43f2686-da2d-4b67-b87e-7c22bd09257c„§cell_idÙ$c43f2686-da2d-4b67-b87e-7c22bd09257c¤codeµresponse_1g = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$b54f8319-dce6-4009-873e-bd47dc2a4619„§cell_idÙ$b54f8319-dce6-4009-873e-bd47dc2a4619¤codeÙšlet
plt = plot_hubble_diagram(df_fit,Hâ‚€_wls_fit, show_yerr=true)
title!(plt,"Fitting only SNs with v < " * string(floor(Int,max_v_plt)) * " km/s")
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7„§cell_idÙ$ddf74f60-42eb-4eab-b77b-b6e78f0e90a7¤codeÙEmd"""**Q1g:** How precise is our estimate of the Hubble constant?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$a6cf5e52-8692-4e3c-95aa-11167b118bd4„§cell_idÙ$a6cf5e52-8692-4e3c-95aa-11167b118bd4¤codeÚ0md"""
Evaluating the posterior PDF direclty is hard (often due to the noramlization constant).
To get around the challenge, Turing allows us to generate samples from the posterior PDF.
There are many interesting algorithms for sampling from a complex posterior distribution.
Here, we'll adopt the ["NUTS" sampler](https://www.mcmchandbook.net/HandbookChapter5.pdf) which based on [Hamiltonian Monte Carlo](https://mc-stan.org/docs/2_19/reference-manual/hamiltonian-monte-carlo.html).
The algorithm is quite complex, so we won't go into the details.
But it's good to konw that this is often a good choice for models with a few to dozens of model parameters.
We'll specify that we want it to draw `num_mcmc_samples` samples and repeat the calculation `num_chains` different times (running in parallel).
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179d„§cell_idÙ$0f6aa1eb-2f89-400f-b1e8-bfc07012179d¤codeÙ0md"""
## Visualize $\chi^2$ or Loss Function
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0991f15c-b734-480b-8b12-6d2beda547db„§cell_idÙ$0991f15c-b734-480b-8b12-6d2beda547db¤codeÚkbegin
# Make a new DataFrame with just data selected for new fit.
df_fit = filter(r->r.v<= max_v_plt, df_all)
# Note that the value of max_v_plt above comes from the slider below
# Fit linear model
wls_fit = lm(formula_wo_intercept, df_fit, wts=weights(df_fit.σ_dₗ.^(-2)))
# Store best-fit value of H_0 for new fit
Hâ‚€_wls_fit = 1/coef(wls_fit)[1]
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$5c9b0395-4d2e-4679-8d86-b9581fa0f66c„§cell_idÙ$5c9b0395-4d2e-4679-8d86-b9581fa0f66c¤codeÙbmd"""
# Fitting a Model to Data
## Computing Maximum Likelihood Estimator for model parameters
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$340dc0ff-dd1c-44e0-907c-f357adb122d5„§cell_idÙ$340dc0ff-dd1c-44e0-907c-f357adb122d5¤codeÙqmodel_hubble_law_uniform_prior_given_data = model_hubble_law_uniform_prior(df_fit.v, df_fit.dâ‚—, df_fit.σ_dâ‚—)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$0c25a4cc-9f53-4729-985b-de692278c433„§cell_idÙ$0c25a4cc-9f53-4729-985b-de692278c433¤codeµresponse_1d = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$ad758d43-b135-418e-a29c-36cea3a24457„§cell_idÙ$ad758d43-b135-418e-a29c-36cea3a24457¤codeÚ aside(tip(md"""
`MvNormal` specifies a multivariate normal distribution with one output for each observation.
The expected value for each observation is $d_\mathrm{true}$ and the standard deviation of each measurement is given by $\sigma_{d,\mathrm{obs}}$.
In principle, we could pass a covariance matrix for the second argument to describe correlated measurement uncertainties.
Instead, we've provided a vector for the second arguement, asking for a model that assume uncorrelated measurement errors."""))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$18edb530-8472-4932-946c-917d8ab9dbde„§cell_idÙ$18edb530-8472-4932-946c-917d8ab9dbde¤codeÙFif chain_lognormal_prior!= nothing
describe(chain_lognormal_prior)
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2b3729fc-62b2-478d-b35c-e69e6b0efc93„§cell_idÙ$2b3729fc-62b2-478d-b35c-e69e6b0efc93¤codeÚÃ"""
`plot_hubble_diagram(df, Hâ‚€; show_yerr, show_resid)`
Plots distance versus velocity.
Adds a line based on linear model of Hubble expansion with rate `Hâ‚€`.
Optionally, plots residuals to model.
"""
function plot_hubble_diagram(df::AbstractDataFrame, Hâ‚€::Real;
show_yerr::Bool=false, show_resid::Bool=false)
@assert "v" ∈ names(df)
@assert "dₗ" ∈ names(df)
@assert "σ_dₗ" ∈ names(df)
@assert size(df,1) >= 2
x_pred = range(0,stop=maximum(df.v), length=10)
y_pred = predict_linear_model(reshape(x_pred,length(x_pred),1), [1/Hâ‚€])
plt = plot(x_pred,y_pred, label="Hâ‚€ = " * string(round(Hâ‚€,digits=2)) * " km/s/Mpc")
if show_yerr
scatter!(plt,df.v,df.dₗ, yerr=df.σ_dₗ, label=:none)
else
scatter!(plt,df.v,df.dâ‚—, label=:none)
end
xlabel!(plt,"v (km/s)")
ylabel!(plt,"D (Mpc)")
plt
if show_resid
y_pred = predict_linear_model(reshape(df.v,size(df,1),1), [1/Hâ‚€])
plt2 = plot()
if show_yerr
scatter!(plt2,df.v, df.dₗ.-y_pred, yerr=df.σ_dₗ, label=:none)
else
scatter!(plt2,df.v, df.dâ‚—.-y_pred, label=:none)
end
xlabel!(plt2,"v (km/s)")
ylabel!(plt2,"Residual D (Mpc)")
return plot(plt,plt2,layout=(2,1))
else
return plt
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$92af3764-6c53-4e03-a338-81b1de202a04„§cell_idÙ$92af3764-6c53-4e03-a338-81b1de202a04¤codeÙ.md"""
### Computing MLE via Linear Algebra
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$0a998eb0-4bf5-4d4e-b193-54964b54f1ab„§cell_idÙ$0a998eb0-4bf5-4d4e-b193-54964b54f1ab¤codeÚ1md"""
One disadvantage of using simple text files to share data is that they don't have a uniform way to store **metadata** about the file. For example, it would be nice to include a longer description of the of each column. So after we've read in the datafile, we can add that metadata ourselves.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$8ab41174-d7d9-42c7-8129-381c54906280„§cell_idÙ$8ab41174-d7d9-42c7-8129-381c54906280¤codeÚmd"""
Thinking a little more broadly, sometimes the goodness-of-fit statistic that we want to minimize is more complicated. So often people refer to minimizing an **objective function** or a **loss function**.
We'll implement a $\chi^2$ loss function below.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$7f61c098-1c54-4c82-be40-f9fd154156a1„§cell_idÙ$7f61c098-1c54-4c82-be40-f9fd154156a1¤codeÚdetails("Choice of Priors",
md"""
The choice of prior probability distributions is often subjective.
For example, one astronomer might say that they want to assume as little as practical about the Hubble constant.
This has some philosophical appeal, but it can be tricky to put into practice.
For example, should we assume that the Hubble constant is positive?
Should we assume that there's some maximum velocity (maybe the speed of light)?
Should we assume that very large Hubble constants are less likely that small values? If so, what counts as "large"?
Another astronomer might take a different approach and want to approximation to our prior knowledge about the value of the Hubble constant based on previous studies (critically, **excluding** the data that is currently being analyzing).
This also comes with follow-up questions.
Should we approximate our prior knowledge with a simple, named distribution?
Or should we use a more complex prior to better describe the conclusions of previous research?
There are almost always some very bad choices for priors.
But often there's not a single best choice.
Rather than trying to find "the correct" prior, it's often wise to perform multiple analyses with multiple reasonable choices for priors.
You may find the the difference in outcome are so small that they don't affect your conclusions.
Or you might discover than even small differences in the choice of the priors can have a substantive impact on the conclusions.
Knowing which regime you're in is often more a valuable result than computing the result under one single choice of priors.
Here, if we assumed a broad uniform prior for $H_0$, then the maximum a posteriori estimate (MAP) would match the MLE.
Altneratively, we might adopt as [Log-Normal distribution](https://en.wikipedia.org/wiki/Normal_distribution), since it has non-zero probability for all positive values and we're able to pick a location for the peak and scale that are qualitatively similar to what we had already learned from previous studies.
""")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$ef78506f-0326-4bd0-8fb3-af6f34a06841„§cell_idÙ$ef78506f-0326-4bd0-8fb3-af6f34a06841¤codeÙÎaside(tip(md"To type unicode characters like σ, first type `\`, then the name of the character your want (e.g., 'sigma'), then press tab. For the subscript `ₜ`, you'd type `\_t`+`TAB`."), v_offset=-180)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$316f65a1-9062-4cb0-a3fb-af54149afb4d„§cell_idÙ$316f65a1-9062-4cb0-a3fb-af54149afb4d¤codeÙSplot_hubble_diagram(df_all,Hâ‚€_plt_1; show_yerr = plt_yerr, show_resid=plt_resid )¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$8ddbc921-4541-4c45-90c5-5c51ec2e391a„§cell_idÙ$8ddbc921-4541-4c45-90c5-5c51ec2e391a¤codeÙ,ols_all = lm(@formula(dâ‚— ~ 0 + v), df_all)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d67f0b9e-10be-4511-93ab-edceb3aef49c„§cell_idÙ$d67f0b9e-10be-4511-93ab-edceb3aef49c¤codeÙ%Hâ‚€_wls_all = 1.0 / coef(wls_all)[1]¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$1eb1face-a795-4cb3-9c51-f995f73e2509„§cell_idÙ$1eb1face-a795-4cb3-9c51-f995f73e2509¤codeÚ:if chain_uniform_prior!=nothing
let
bins = range(floor(minimum(chain_uniform_prior[:Hâ‚€])),
stop=ceil(maximum(chain_uniform_prior[:Hâ‚€])), step=0.1)
plt = histogram_or_density(chain_uniform_prior, bins = bins, alpha=0.3, lw=3)
xlabel!(plt, "Hâ‚€")
title!(plt,"Posterior Samples (Uniform Prior)")
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$ccdf5418-12e4-49ee-bdea-90efc202583a„§cell_idÙ$ccdf5418-12e4-49ee-bdea-90efc202583a¤codeÙÌlet
if !ismissing(response_1f)
ϵ = 1e-4
d2lossdH₀2_fit = (loss(H₀_fit+ϵ,df_fit)+loss(H₀_fit-ϵ,df_fit)-2*loss(H₀_fit,df_fit))/(ϵ^2)
σ_H₀_fit_deriv_fit = sqrt(2/(d2lossdH₀2_fit))
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$2efb7fb2-0402-4eec-b58a-a52fd530e3f5„§cell_idÙ$2efb7fb2-0402-4eec-b58a-a52fd530e3f5¤code¿md"""
## Read the Data file
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3a06141a-a92d-4c31-9950-13f0bf2c023a„§cell_idÙ$3a06141a-a92d-4c31-9950-13f0bf2c023a¤codeÙ.if ismissing(response_1g)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$bf7ca6ea-4c07-46e4-baff-b205e1663505„§cell_idÙ$bf7ca6ea-4c07-46e4-baff-b205e1663505¤code¾md"""
#### $title
# $topic
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2656d886-60dc-44a7-b318-100335dcf05b„§cell_idÙ$2656d886-60dc-44a7-b318-100335dcf05b¤codeÙ.formula_wo_intercept = @formula(dâ‚— ~ 0 + v);¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$2c1c7d8a-eda6-4900-9be7-e4b908fed81a„§cell_idÙ$2c1c7d8a-eda6-4900-9be7-e4b908fed81a¤codeÙ4begin
num_mcmc_samples = 2_000
num_chains = 3
end;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861„§cell_idÙ$a1eb8ff3-ff5b-4e50-a75c-480cf2a7d861¤codeÙê"""
`predict_linear_model(A, θ)`
Computes the predictions of a linear model with design matrix `A` and parameters `θ`.
"""
function predict_linear_model(A::AbstractMatrix, b::AbstractVector)
@assert size(A,2) == length(b)
A*b
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9ef67704-5063-4f75-853b-078261e50684„§cell_idÙ$9ef67704-5063-4f75-853b-078261e50684¤codeÙ¡md"""
Now we'll call a function (implemented at the bottom of the notebook) to compute the best-fit model parameters for a linear model using linear algebra.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$095bdd00-ffa9-434d-9fc5-0978019b060b„§cell_idÙ$095bdd00-ffa9-434d-9fc5-0978019b060b¤codeÙebegin
# Scratch cell for any optional calculations to check out concerns to be described in Q1b.
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21„§cell_idÙ$3f2ef930-d367-11ef-3b5c-95b4989c2e21¤codeÚYbegin
mkpath("data")
filename = joinpath("data","SCPUnion2.1_mu_vs_z.txt")
if split(pwd(),'/')[end] == "test"
filename = "../" * filename
end
url = "http://supernova.lbl.gov/Union/figures/SCPUnion2.1_mu_vs_z.txt"
if !(filesize(filename)>0)
Downloads.download(url,filename)
@assert filesize(filename)>0
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3„§cell_idÙ$299e9d1f-bbb2-4fc3-8682-51c3daab0ba3¤codeµresponse_1c = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$ac1a64e8-7a5c-43b5-923a-633dac4fb664„§cell_idÙ$ac1a64e8-7a5c-43b5-923a-633dac4fb664¤codeÙÛmd"""
A vector containing each distance measurement,
$y_{\mathrm{obs}} =
\left(
\begin{matrix}
d_{\mathrm{obs},1} \\
d_{\mathrm{obs},1} \\
\ddots \\
d_{\mathrm{obs},N_{\mathrm{obs}}} \\
\end{matrix}
\right),$
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d9058d92-b1c9-44f2-af5c-3540932dec48„§cell_idÙ$d9058d92-b1c9-44f2-af5c-3540932dec48¤codeÙ,A_all = reshape(df_all.v, size(df_all,1), 1)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$0e42628b-95a9-45a0-b375-51f62dc0ce0d„§cell_idÙ$0e42628b-95a9-45a0-b375-51f62dc0ce0d¤codeÙ.if ismissing(response_1c)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8„§cell_idÙ$e09e30f7-838f-4571-bb9c-6d0b425807a8¤codeÙX# hideall
md"""
+++
title = $title
week_num = $week
topic = $topic
+++
""" |> Base.Text;¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$a2b56e1c-9735-49b0-91da-40f489823390„§cell_idÙ$a2b56e1c-9735-49b0-91da-40f489823390¤codeÚlaside(tip(md"""We could have created the matrix with the `diagm` function. Instead, we used `PDiagMat` to create a matrix that the computer knows will always be diagonal and positive definite. This allows it to use algorithms that are faster and/or more robust than if it couldn't assume anything about the propeties of the covariance matrix."""),v_offset=-280)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348„§cell_idÙ$4dcd9f29-8dd5-40ff-9ce9-50bd38f33348¤codeÙÀmd"""**Q1f:** What velocity threshold did you pick? What is the results best-fit Hubble constant? How does this compare to the best-fit Hubble constant when fitting to the full data set?"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$e4ca4972-42c8-4426-94ae-e316662513c3„§cell_idÙ$e4ca4972-42c8-4426-94ae-e316662513c3¤codeÙBmd"""
### Computing MLE with package for General Linear Models
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$6a75dd68-5034-4b16-89a0-7388cfae0cbd„§cell_idÙ$6a75dd68-5034-4b16-89a0-7388cfae0cbd¤codeÙGmd"""
We'll package the velocities and uncertainties into matrices.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d68dd4b4-c091-4435-a286-3de589b19009„§cell_idÙ$d68dd4b4-c091-4435-a286-3de589b19009¤codeÚ§md"""
For a linear model, we can estimate the measurement uncertainty associated with our maximum likelihood estimators.
It's most intuitive to plot the $\Delta\chi^2$ as a function of $H_0$.
By construction, the slope of $\chi^2(H_0)$ is zero at the best-fit value.
The magnitude of the measurement uncertainty is inversely proportional to the curvature (absolute value of the second derivative) of $\chi^2(H_0)$.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$33045766-a7c5-42ff-bdf8-bde1fce9c56b„§cell_idÙ$33045766-a7c5-42ff-bdf8-bde1fce9c56b¤codeÙ.if ismissing(response_2a)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9555ae09-be3d-48e8-9ee2-face2bef8cce„§cell_idÙ$9555ae09-be3d-48e8-9ee2-face2bef8cce¤codeÙ5md"""
## Fitting model to a subset of the dataset
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$466dacda-1835-42fd-b8f4-cac5c22f6756„§cell_idÙ$466dacda-1835-42fd-b8f4-cac5c22f6756¤codeÙ)ols_try1 = lm(@formula(dâ‚— ~ v), df_all)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64da„§cell_idÙ$915fc532-7d8d-4ff5-81fd-af8f6e9e64da¤codeÚ7if chain_lognormal_prior!=nothing
let
bins = range(floor(minimum(vcat(chain_uniform_prior[:Hâ‚€],chain_lognormal_prior[:Hâ‚€]))),
stop=ceil(maximum(vcat(chain_uniform_prior[:Hâ‚€],chain_lognormal_prior[:Hâ‚€]))), step=0.1)
plt1 = histogram_or_density(chain_lognormal_prior, bins=bins, alpha=0.3, lw=3)
xlabel!(plt1, "")
title!(plt1,"Posterior Samples (Uniform Prior)")
plt2 = histogram_or_density(chain_uniform_prior, bins=bins, alpha=0.3,lw=3)
xlabel!(plt2, "Hâ‚€")
title!(plt2,"Posterior Samples (LogNormal Prior)")
plot(plt1,plt2,layout=(2,1))
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$fb2545e1-d624-4669-9e07-c94a598ba8ed„§cell_idÙ$fb2545e1-d624-4669-9e07-c94a598ba8ed¤codeÙ.if ismissing(response_2c)
still_missing()
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04a„§cell_idÙ$67e9aa94-2d3a-4888-97b7-c2cb019eb04a¤codeÙÕlet
if !ismissing(response_1f)
ϵ = 1e-4
d2lossdH₀2_all = (loss(H₀_bf_all+ϵ,df_all)+loss(H₀_bf_all-ϵ,df_all)-2*loss(H₀_bf_all,df_all))/(ϵ^2)
σ_H₀_fit_deriv_all = sqrt(2/(d2lossdH₀2_all))
end
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$389e8239-6f62-46fb-8b13-d336516e5e2f„§cell_idÙ$389e8239-6f62-46fb-8b13-d336516e5e2f¤codeÙ¬let
plt = plot(LogNormal(log(100),1.0), xlims=(0,250), label=:none)
xlabel!(plt,"H_0")
ylabel!(plt,"p(Hâ‚€)")
title!(plt,"Log Normal prior (median 100, scale 1.0)")
end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$54b51239-59b0-4767-9bc8-018d77ee5e44„§cell_idÙ$54b51239-59b0-4767-9bc8-018d77ee5e44¤codeÙÂmd"""
We can plot histograms for each of the calculations.
We can compute an estimtae of the posterior density ($p(H_0|\bf{v},\bf{d},\bf{\sigma_d})$) using the samples from each chain.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617„§cell_idÙ$d62cf934-a592-482b-b0b3-7fd55f9e0617¤codeÚ~md"""
Or we can use an analytic expression for the uncertainty for parameters estimated from a general linear model,
$$E\left[\mathrm{Covar}(\theta)\right] = (A' \Sigma^{-1} A)^{-1}$$
and propagate the uncertainties for $H_0$.
We'll skip the tedious derivation, but you can see the implementation in the function `calc_sigma_mle_linear_model` at the bottom of this notebook.
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$aab05339-dea2-4c7f-8b38-bc7d7971f1d9„§cell_idÙ$aab05339-dea2-4c7f-8b38-bc7d7971f1d9¤code»md"""
## Functions used
"""¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$46eb1088-0265-46a6-91ec-44dfa3bd862d„§cell_idÙ$46eb1088-0265-46a6-91ec-44dfa3bd862d¤codeÙwscatter(df_all.v, df_all.dâ‚—, yerr=df_all.σ_dâ‚—, label=:none, xlabel="v (km/s)", ylabel="Luminosity Distance (Mpc)")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$25ef65bd-8b86-4f88-b0b7-32f05ce82ada„§cell_idÙ$25ef65bd-8b86-4f88-b0b7-32f05ce82ada¤codeµresponse_1a = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_folded«notebook_idÙ$48878fcc-de6d-11ef-223b-a1023bf62c62«in_temp_dir¨metadata€