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: ndarray | None
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: float | None
Return the log marginal likelihood (evidence ) if computed
- return:
- property log_probability_values: ndarray | None
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: ndarray | None
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: BayesianResults | None
- 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: SamplerBase | None
Access the instance of the sampler used to sample the posterior distribution :return: an instance of the sampler
- property samples: Dict[str, ndarray] | None
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