threeML.bayesian.bayesian_analysis module
- class threeML.bayesian.bayesian_analysis.BayesianAnalysis(likelihood_model: Model, data_list: DataList, **kwargs)[source]
Bases:
object
- property analysis_type: str
- convergence_plots(n_samples_in_each_subset, n_subsets)[source]
Compute the mean and variance for subsets of the samples, and plot them. They should all be around the same values if the MCMC has converged to the posterior distribution.
The subsamples are taken with two different strategies: the first is to slide a fixed-size window, the second is to take random samples from the chain (bootstrap)
- Parameters
n_samples_in_each_subset – number of samples in each subset
n_subsets – number of subsets to take for each strategy
- Returns
a matplotlib.figure instance
- property likelihood_model: Model
likelihood model (a Model instance)
- Type
return
- property log_like_values: Optional[ndarray]
Returns the value of the log_likelihood found by the bayesian sampler while sampling from the posterior. If you need to find the values of the parameters which generated a given value of the log. likelihood, remember that the samples accessible through the property .raw_samples are ordered in the same way as the vector returned by this method.
- Returns
a vector of log. like values
- property log_marginal_likelihood: Optional[float]
Return the log marginal likelihood (evidence ) if computed
- return
- property log_probability_values: Optional[ndarray]
Returns the value of the log_probability (posterior) found by the bayesian sampler while sampling from the posterior. If you need to find the values of the parameters which generated a given value of the log. likelihood, remember that the samples accessible through the property .raw_samples are ordered in the same way as the vector returned by this method.
- Returns
a vector of log probabilty values
- plot_chains(thin=None)[source]
Produce a plot of the series of samples for each parameter
- Parameters
thin – use only one sample every ‘thin’ samples
- Returns
a matplotlib.figure instance
- property raw_samples: Optional[ndarray]
Access the samples from the posterior distribution generated by the selected sampler in raw form (i.e., in the format returned by the sampler)
- Returns
the samples as returned by the sampler
- property results: Optional[BayesianResults]
- sample(quiet=False) None [source]
sample the posterior of the model with the selected algorithm
If no algorithm as been set, then the configured default algorithm we default parameters will be run
- Parameters
quiet – if True, then no output is displayed
- Returns
- property sampler: Optional[SamplerBase]
Access the instance of the sampler used to sample the posterior distribution :return: an instance of the sampler
- property samples: Optional[Dict[str, ndarray]]
Access the samples from the posterior distribution generated by the selected sampler
- Returns
a dictionary with the samples from the posterior distribution for each parameter