Exemple #1
0
plt.errorbar(
    x=xvalues, y=data, yerr=noise_map, color="k", ecolor="k", elinewidth=1, capsize=2
)
plt.plot(xvalues, model_data, color="r")
plt.title("Dynesty model fit to 1D Gaussian dataset.")
plt.xlabel("x values of profile")
plt.ylabel("Profile normalization")
plt.show()
plt.close()

"""
The Probability Density Functions (PDF's) of the results can be plotted using Dynesty's in-built visualization tools, 
which are wrapped via the `DynestyPlotter` object.
"""
dynesty_plotter = aplt.DynestyPlotter(samples=result.samples)
dynesty_plotter.cornerplot()

"""
We discuss in more detail how to use a results object in the files `autofit_workspace/example/simple/result.py`.

##################
###### MCMC ######
##################

To use a different non-linear we simply use call a different search from PyAutoFit, passing it the same the model
and analysis as we did before to perform the fit. Below, we fit the same dataset using the MCMC sampler Emcee.
Again, we manually specify all of the Emcee settings, however if they were omitted the values found in the config
file `config/non_linear/Emcee.ini` would be used instead.

For a full description of Emcee, checkout its Github and readthedocs webpages:
Exemple #2
0
Advanced queries can be constructed using logic, for example we below we combine the two queries above to find all
results which fitted a `Gaussian` AND (using the & symbol) inferred a value of sigma less than 3.0. 

The OR logical clause is also supported via the symbol |.
"""
gaussian = agg.gaussian
agg_query = agg.query((gaussian == m.Gaussian) & (gaussian.sigma < 3.0))
samples_gen = agg_query.values("samples")
print(
    "Total Samples Objects In Query `Gaussian & sigma < 3.0` = ",
    len(list(samples_gen)),
    "\n",
)
"""
The Probability Density Functions (PDF's) of the results can be plotted using Dynesty's in-built visualization tools, 
which are wrapped via the `DynestyPlotter` object.
"""
for samples in agg.values("samples"):

    dynesty_plotter = aplt.DynestyPlotter(samples=samples)
    dynesty_plotter.cornerplot()
    dynesty_plotter.runplot()
"""
The API for querying is fairly self explanatory. Through the combination of info based queries, model based
queries and result based queries a user has all the tools they need to fit extremely large datasets with many different
models and load only the results they are interested in for inspection and analysis.

The Database chapter of the **HowToFit** Jupyter notebooks give a full description of the database feature, including 
examples of advanced queries and how to load and plot the results of a model-fit in more detail.
"""
             yerr=noise_map,
             color="k",
             ecolor="k",
             elinewidth=1,
             capsize=2)
plt.plot(xvalues, model_data, color="r")
plt.title("Dynesty model fit to 1D Gaussian dataset.")
plt.xlabel("x values of profile")
plt.ylabel("Profile normalization")
plt.show()
plt.close()
"""
The Probability Density Functions (PDF's) of the results can be plotted using Dynesty's in-built visualization tools, 
which are wrapped via the `DynestyPlotter` object.

This will show reduced errors compared to results one would infer fitting each dataset individually.
"""
dynesty_plotter = aplt.DynestyPlotter(samples=result_list[0].samples)
dynesty_plotter.cornerplot()
"""
__Different Analysis Objects__

The second part of this example which sums together different `Analysis` objects is not written yet. The aim of this
example is to show how even if you have different datasets which are fitted by the model in different ways (e.g. each
with their own `log_likelihood_function` you can use Analysis class summing to easily define a unique Analysis class
for each dataset.

This functionality works in PyAutoFit and can easily be adopted by following the same API shown above, but using your
own Analysis classes.
"""