예제 #1
0
algorithm) are also available.

Given each fit is to a different image, these are not very useful. However, in a later tutorial we'll look at using 
the aggregator for images that we fit with many different models and many different pipelines, in which case comparing 
the evidences allows us to perform Bayesian model comparison!
"""
print("Maximum Log Likelihoods and Log Evidences: \n")
print([max(samps.log_likelihood_list) for samps in agg.values("samples")])
print([samps.log_evidence for samps in agg.values("samples")])

"""
We can also print the "model_results" of all searches, which is string that summarizes every fit`s lens model providing 
quick inspection of all results.
"""
results = agg.model_results
print("Model Results Summary: \n")
print(results, "\n")

"""
The Probability Density Functions (PDF's) of the every model-fit 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()

"""
Finished.
"""
"""
__Model-Fit__

We can now begin the model-fit by passing the model and analysis object to the search, which performs a non-linear
search to find which models fit the data with the highest likelihood.

Checkout the output folder for live outputs of the results of the fit, including on-the-fly visualization of the best 
fit model!
"""
result = search.fit(model=model, analysis=analysis)
"""
__Result__

The search returns a result object, which includes: 

 - The lens model corresponding to the maximum log likelihood solution in parameter space.
 - The corresponding maximum log likelihood `Tracer` object.
 - Information on the posterior as estimated by the `Dynesty` non-linear search.
"""
print(result.max_log_likelihood_instance)

tracer_plotter = aplt.TracerPlotter(tracer=result.max_log_likelihood_tracer,
                                    grid=result.grid)
tracer_plotter.subplot_tracer()

dynesty_plotter = aplt.DynestyPlotter(samples=result.samples)
dynesty_plotter.cornerplot()
"""
Checkout `autolens_workspace/notebooks/modeling/results.py` for a full description of the result object.
"""