Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Dec 29, 2024
1 parent 8aba3f7 commit 2caca55
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aa802b7b
f2d4c74a
16 changes: 8 additions & 8 deletions examples/data_analysis/snia.html
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ <h1 class="title">Supernova Type Ia Analysis</h1>


<div class="hidden">
<div id="f1302fd2" class="cell" data-execution_count="1">
<div id="67914e07" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> doc_theme():</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> theme_minimal() <span class="op">+</span> theme(</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> panel_grid_minor<span class="op">=</span>element_line(color<span class="op">=</span><span class="st">"gray"</span>, linetype<span class="op">=</span><span class="st">"--"</span>),</span>
Expand All @@ -344,7 +344,7 @@ <h1 class="title">Supernova Type Ia Analysis</h1>
<section id="computational-cosmology" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="computational-cosmology">Computational Cosmology</h2>
<p>NumCosmo provides tools for calculating cosmological observables with precision. For example, the comoving distance in an XCDM cosmology up to a redshift of <span class="math inline">\(z = 3.0\)</span> can be computed with a few lines of code using the parameters <span class="math inline">\(\Omega_{c0} = 0.25\)</span>, <span class="math inline">\(\Omega_{b0} = 0.05\)</span>, and <span class="math inline">\(w\)</span> varying from <span class="math inline">\(-1.5\)</span> to <span class="math inline">\(-0.5\)</span>.</p>
<div id="d2eb331c" class="cell" data-execution_count="2">
<div id="1ee42612" class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pandas <span class="im">as</span> pd</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> plotnine <span class="im">import</span> <span class="op">*</span></span>
Expand Down Expand Up @@ -403,7 +403,7 @@ <h2 class="anchored" data-anchor-id="computational-cosmology">Computational Cosm
<section id="the-modeling" class="level3">
<h3 class="anchored" data-anchor-id="the-modeling">The Modeling</h3>
<p>NumCosmo’s computational objects are designed for direct use in statistical analyses. In the example above, the <code>HICosmoDEXcdm</code> class defines the cosmological model, which is a subclass of the <code>HICosmo</code> class representing a homogeneous isotropic cosmology. The model’s parameters can be accessed and managed within a model set, using the <code>MSet</code> class, which serves as the main container for all models in a given analysis.</p>
<div id="a577d18c" class="cell" data-execution_count="4">
<div id="598e6444" class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>mset <span class="op">=</span> Ncm.MSet.new_array([cosmo])</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>mset.pretty_log()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
Expand All @@ -427,7 +427,7 @@ <h3 class="anchored" data-anchor-id="the-modeling">The Modeling</h3>
<section id="fitting-model-to-data" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="fitting-model-to-data">Fitting Model to Data</h2>
<p>Once models are defined and the free parameters are set, they can be analyzed using a variety of statistical methods. For example, the best-fit parameters for a given model can be found by maximizing the likelihood function.</p>
<div id="c641b5e0" class="cell" data-execution_count="5">
<div id="d803f281" class="cell" data-execution_count="5">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>cosmo.props.w_fit <span class="op">=</span> <span class="va">True</span></span>
Expand All @@ -454,7 +454,7 @@ <h2 class="anchored" data-anchor-id="fitting-model-to-data">Fitting Model to Dat
# - differentiation: Numerical differentiantion (forward)
#................
# Minimum found with precision: |df|/f = 1.00000e-08 and |dx| = 1.00000e-05
# Elapsed time: 00 days, 00:00:00.8651910
# Elapsed time: 00 days, 00:00:00.8537400
# iteration [000074]
# function evaluations [000076]
# gradient evaluations [000000]
Expand Down Expand Up @@ -487,7 +487,7 @@ <h2 class="anchored" data-anchor-id="fitting-model-to-data">Fitting Model to Dat
</div>
</div>
<p>The code above fits the XCDM model to the Union2.1 dataset, which contains supernova type Ia data. It computes the best-fit parameters for the model and the covariance matrix of the parameters using the Fisher matrix.</p>
<div id="c300ab2a" class="cell" data-execution_count="6">
<div id="e1847564" class="cell" data-execution_count="6">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>lhr2d <span class="op">=</span> Ncm.LHRatio2d.new(</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> fit,</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> mset.fparam_get_pi_by_name(<span class="st">"Omegac"</span>),</span>
Expand Down Expand Up @@ -555,7 +555,7 @@ <h2 class="anchored" data-anchor-id="fitting-model-to-data">Fitting Model to Dat
<section id="running-a-mcmc-analysis" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="running-a-mcmc-analysis">Running a MCMC Analysis</h2>
<p>NumCosmo also provides tools for running Markov Chain Monte Carlo (MCMC) analyses. The code below runs an MCMC analysis using the <code>APES</code> algorithm.</p>
<div id="92c2ed04" class="cell" data-execution_count="8">
<div id="975cd07d" class="cell" data-execution_count="8">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>init_sampler <span class="op">=</span> Ncm.MSetTransKernGauss.new(<span class="dv">0</span>)</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>init_sampler.set_mset(mset)</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>init_sampler.set_prior_from_mset()</span>
Expand All @@ -570,7 +570,7 @@ <h2 class="anchored" data-anchor-id="running-a-mcmc-analysis">Running a MCMC Ana
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a>esmcmc.end_run()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Finally, we can extract the MCMC samples and visualize the results.</p>
<div id="fig-mcmc-results" class="cell quarto-float quarto-figure quarto-figure-center anchored page-columns page-full" data-fig-cap-location="margin" data-execution_count="9">
<div id="fig-mcmc-results" class="cell quarto-float quarto-figure quarto-figure-center anchored page-columns page-full" data-execution_count="9" data-fig-cap-location="margin">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-mcmc-results-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>mcat <span class="op">=</span> esmcmc.peek_catalog()</span>
Expand Down
2 changes: 1 addition & 1 deletion search.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"href": "examples/data_analysis/snia.html#fitting-model-to-data",
"title": "Supernova Type Ia Analysis",
"section": "Fitting Model to Data",
"text": "Fitting Model to Data\nOnce models are defined and the free parameters are set, they can be analyzed using a variety of statistical methods. For example, the best-fit parameters for a given model can be found by maximizing the likelihood function.\n\n\nCode\ncosmo.props.w_fit = True\ncosmo.props.Omegac_fit = True\nmset.prepare_fparam_map()\n\nlh = Ncm.Likelihood(\n dataset=Ncm.Dataset.new_array(\n [Nc.DataDistMu.new_from_id(dist, Nc.DataSNIAId.SIMPLE_UNION2_1)]\n )\n)\nfit = Ncm.Fit.factory(\n Ncm.FitType.NLOPT, \"ln-neldermead\", lh, mset, Ncm.FitGradType.NUMDIFF_FORWARD\n)\nfit.run(Ncm.FitRunMsgs.SIMPLE)\nfit.log_info()\nfit.fisher()\nfit.log_covar()\n\n\n#----------------------------------------------------------------------------------\n# Model fitting. Interating using:\n# - solver: NLOpt:ln-neldermead\n# - differentiation: Numerical differentiantion (forward)\n#................\n# Minimum found with precision: |df|/f = 1.00000e-08 and |dx| = 1.00000e-05\n# Elapsed time: 00 days, 00:00:00.8651910\n# iteration [000074]\n# function evaluations [000076]\n# gradient evaluations [000000]\n# degrees of freedom [000577]\n# m2lnL = 562.219163105043 ( 562.21916 )\n# Fit parameters:\n# 0.230499952926549 -1.02959391499341 \n#----------------------------------------------------------------------------------\n# Data used:\n# - Union2.1 sample\n#----------------------------------------------------------------------------------\n# Model[03000]:\n# - NcHICosmo : XCDM - Constant EOS\n#----------------------------------------------------------------------------------\n# Model parameters\n# - H0[00]: 67.36 [FIXED]\n# - Omegac[01]: 0.230499952926549 [FREE]\n# - Omegax[02]: 0.7 [FIXED]\n# - Tgamma0[03]: 2.7245 [FIXED]\n# - Yp[04]: 0.24 [FIXED]\n# - ENnu[05]: 3.046 [FIXED]\n# - Omegab[06]: 0.05 [FIXED]\n# - w[07]: -1.02959391499341 [FREE]\n#----------------------------------------------------------------------------------\n# NcmMSet parameters covariance matrix\n# -------------------------------\n# Omegac[03000:01] = 0.2305 +/- 0.06233 | 1 | -0.9297 |\n# w[03000:07] = -1.03 +/- 0.08595 | -0.9297 | 1 |\n# -------------------------------\n\n\nThe code above fits the XCDM model to the Union2.1 dataset, which contains supernova type Ia data. It computes the best-fit parameters for the model and the covariance matrix of the parameters using the Fisher matrix.\n\nlhr2d = Ncm.LHRatio2d.new(\n fit,\n mset.fparam_get_pi_by_name(\"Omegac\"),\n mset.fparam_get_pi_by_name(\"w\"),\n 1.0e-3,\n)\n\nbest_fit = pd.DataFrame(\n {\n \"Omegac\": [cosmo.props.Omegac],\n \"w\": [cosmo.props.w],\n \"sigma\": \"Best-fit\",\n \"region\": \"Best-fit\",\n }\n)\n\n\nregions_pd_list = []\nfor i, sigma in enumerate(\n [Ncm.C.stats_1sigma(), Ncm.C.stats_2sigma(), Ncm.C.stats_3sigma()]\n):\n fisher_rg = lhr2d.fisher_border(sigma, 300.0, Ncm.FitRunMsgs.NONE)\n Omegac_a = np.array(fisher_rg.p1.dup_array())\n w_a = np.array(fisher_rg.p2.dup_array())\n regions_pd_list.append(\n pd.DataFrame(\n {\n \"Omegac\": Omegac_a,\n \"w\": w_a,\n \"sigma\": rf\"{i+1}$\\sigma$\",\n \"region\": \"Fisher\",\n }\n )\n )\n\nregions_pd = pd.concat(regions_pd_list)\n\nThe code above computes the confidence regions for the best-fit parameters using the Fisher matrix.\n\n\nCode\n(\n ggplot(regions_pd, aes(\"Omegac\", \"w\", fill=\"sigma\", color=\"sigma\"))\n + geom_polygon(alpha=0.3)\n + geom_point(data=best_fit)\n + labs(x=r\"$\\Omega_c$\", y=r\"$w$\", fill=r\"Confidence\")\n + guides(fill=guide_legend(), color=False)\n + doc_theme()\n)\n\n\n\n\n\n\n\n\nFigure 2: Best-fit parameters and confidence regions for the XCDM model.",
"text": "Fitting Model to Data\nOnce models are defined and the free parameters are set, they can be analyzed using a variety of statistical methods. For example, the best-fit parameters for a given model can be found by maximizing the likelihood function.\n\n\nCode\ncosmo.props.w_fit = True\ncosmo.props.Omegac_fit = True\nmset.prepare_fparam_map()\n\nlh = Ncm.Likelihood(\n dataset=Ncm.Dataset.new_array(\n [Nc.DataDistMu.new_from_id(dist, Nc.DataSNIAId.SIMPLE_UNION2_1)]\n )\n)\nfit = Ncm.Fit.factory(\n Ncm.FitType.NLOPT, \"ln-neldermead\", lh, mset, Ncm.FitGradType.NUMDIFF_FORWARD\n)\nfit.run(Ncm.FitRunMsgs.SIMPLE)\nfit.log_info()\nfit.fisher()\nfit.log_covar()\n\n\n#----------------------------------------------------------------------------------\n# Model fitting. Interating using:\n# - solver: NLOpt:ln-neldermead\n# - differentiation: Numerical differentiantion (forward)\n#................\n# Minimum found with precision: |df|/f = 1.00000e-08 and |dx| = 1.00000e-05\n# Elapsed time: 00 days, 00:00:00.8537400\n# iteration [000074]\n# function evaluations [000076]\n# gradient evaluations [000000]\n# degrees of freedom [000577]\n# m2lnL = 562.219163105043 ( 562.21916 )\n# Fit parameters:\n# 0.230499952926549 -1.02959391499341 \n#----------------------------------------------------------------------------------\n# Data used:\n# - Union2.1 sample\n#----------------------------------------------------------------------------------\n# Model[03000]:\n# - NcHICosmo : XCDM - Constant EOS\n#----------------------------------------------------------------------------------\n# Model parameters\n# - H0[00]: 67.36 [FIXED]\n# - Omegac[01]: 0.230499952926549 [FREE]\n# - Omegax[02]: 0.7 [FIXED]\n# - Tgamma0[03]: 2.7245 [FIXED]\n# - Yp[04]: 0.24 [FIXED]\n# - ENnu[05]: 3.046 [FIXED]\n# - Omegab[06]: 0.05 [FIXED]\n# - w[07]: -1.02959391499341 [FREE]\n#----------------------------------------------------------------------------------\n# NcmMSet parameters covariance matrix\n# -------------------------------\n# Omegac[03000:01] = 0.2305 +/- 0.06233 | 1 | -0.9297 |\n# w[03000:07] = -1.03 +/- 0.08595 | -0.9297 | 1 |\n# -------------------------------\n\n\nThe code above fits the XCDM model to the Union2.1 dataset, which contains supernova type Ia data. It computes the best-fit parameters for the model and the covariance matrix of the parameters using the Fisher matrix.\n\nlhr2d = Ncm.LHRatio2d.new(\n fit,\n mset.fparam_get_pi_by_name(\"Omegac\"),\n mset.fparam_get_pi_by_name(\"w\"),\n 1.0e-3,\n)\n\nbest_fit = pd.DataFrame(\n {\n \"Omegac\": [cosmo.props.Omegac],\n \"w\": [cosmo.props.w],\n \"sigma\": \"Best-fit\",\n \"region\": \"Best-fit\",\n }\n)\n\n\nregions_pd_list = []\nfor i, sigma in enumerate(\n [Ncm.C.stats_1sigma(), Ncm.C.stats_2sigma(), Ncm.C.stats_3sigma()]\n):\n fisher_rg = lhr2d.fisher_border(sigma, 300.0, Ncm.FitRunMsgs.NONE)\n Omegac_a = np.array(fisher_rg.p1.dup_array())\n w_a = np.array(fisher_rg.p2.dup_array())\n regions_pd_list.append(\n pd.DataFrame(\n {\n \"Omegac\": Omegac_a,\n \"w\": w_a,\n \"sigma\": rf\"{i+1}$\\sigma$\",\n \"region\": \"Fisher\",\n }\n )\n )\n\nregions_pd = pd.concat(regions_pd_list)\n\nThe code above computes the confidence regions for the best-fit parameters using the Fisher matrix.\n\n\nCode\n(\n ggplot(regions_pd, aes(\"Omegac\", \"w\", fill=\"sigma\", color=\"sigma\"))\n + geom_polygon(alpha=0.3)\n + geom_point(data=best_fit)\n + labs(x=r\"$\\Omega_c$\", y=r\"$w$\", fill=r\"Confidence\")\n + guides(fill=guide_legend(), color=False)\n + doc_theme()\n)\n\n\n\n\n\n\n\n\nFigure 2: Best-fit parameters and confidence regions for the XCDM model.",
"crumbs": [
"About NumCosmo",
"Examples",
Expand Down
Loading

0 comments on commit 2caca55

Please sign in to comment.