autofit.SamplesNest#

class autofit.SamplesNest(model: AbstractPriorModel, sample_list: List[Sample], samples_info: Optional[Dict] = None)[source]#

Bases: SamplesPDF

Contains the samples of the non-linear search, including parameter values, log likelihoods, weights and other quantites.

For example, the output class can be used to load an instance of the best-fit model, get an instance of any individual sample by the NonLinearSearch and return information on the likelihoods, errors, etc.

Parameters:
  • model – Maps input vectors of unit parameter values to physical values and model instances via priors.

  • sample_list – The list of Samples which contains the paramoeters, likelihood, weights, etc. of every sample taken by the non-linear search.

  • number_live_points – The number of live points used by the nested sampler.

  • samples_info – Contains information on the samples (e.g. total iterations, time to run the search, etc.).

Methods

draw_randomly_via_pdf

The parameter vector of an individual sample of the non-linear search drawn randomly from the PDF, returned as a 1D list.

error_magnitudes_at_sigma

The magnitude of every error after marginalization in 1D at an input sigma value of the probability density function (PDF), returned as two lists of values corresponding to the lower and upper errors.

errors_at_lower_sigma

The lower error of every parameter marginalized in 1D at an input sigma value of its probability density function (PDF), returned as a list.

errors_at_sigma

The lower and upper error of every parameter marginalized in 1D at an input sigma value of its probability density function (PDF), returned as a list.

errors_at_upper_sigma

The upper error of every parameter marginalized in 1D at an input sigma value of its probability density function (PDF), returned as a list.

from_list_info_and_model

from_sample_index

The parameters of an individual sample of the non-linear search, returned as a model instance.

from_table

Write a table of parameters, posteriors, priors and likelihoods

info_to_json

max_log_likelihood

The parameters of the maximum log likelihood sample of the NonLinearSearch returned as a model instance or list of values.

max_log_posterior

The parameters of the maximum log posterior sample of the NonLinearSearch returned as a model instance.

median_pdf

The median of the probability density function (PDF) of every parameter marginalized in 1D, returned as a model instance or list of values.

minimise

A copy of this object with only important samples retained

model_absolute

Returns a model where every free parameter is a GaussianPrior with mean the previous result's inferred maximum log likelihood parameter values and sigma the input absolute value a.

model_bounded

Returns a model where every free parameter is a UniformPrior with lower_limit and upper_limit the previous result's inferred maximum log likelihood parameter values minus and plus the bound `b.

model_relative

Returns a model where every free parameter is a GaussianPrior with mean the previous result's inferred maximum log likelihood parameter values and sigma a relative value from the result r.

offset_values_via_input_values

The values of an input_vector offset by the median_pdf(as_instance=False) (the PDF medians).

path_map_for_model

samples_above_weight_threshold_from

Returns a new Samples object containing only the samples with a weight above the input threshold.

samples_within_parameter_range

Returns a new set of Samples where all points without parameter values inside a specified range removed.

save_covariance_matrix

Save the covariance matrix as a CSV file.

subsamples

summary

values_at_lower_sigma

The lower value of every parameter marginalized in 1D at an input sigma value of its probability density function (PDF), returned as a list.

values_at_sigma

The value of every parameter marginalized in 1D at an input sigma value of its probability density function (PDF), returned as two lists of values corresponding to the lower and upper values parameter values.

values_at_upper_sigma

The upper value of every parameter marginalized in 1D at an input sigma value of its probability density function (PDF), returned as a list.

values_for_path

Returns the value for a variable with a given path for each sample in the model

with_paths

Create a copy of this object with only attributes specified by a list of paths.

without_paths

Create a copy of this object with only attributes not specified by a list of paths.

write_table

Write a table of parameters, posteriors, priors and likelihoods.

Attributes

acceptance_ratio

The ratio of accepted samples to total samples.

covariance_matrix

Compute the covariance matrix of the non-linear search samples, using the method np.cov() which is described at the following link:

instance

instances

One model instance for each sample

log_evidence

log_likelihood

log_likelihood_list

log_posterior_list

log_prior_list

max_log_likelihood_index

The index of the sample with the highest log likelihood.

max_log_likelihood_sample

The index of the sample with the highest log likelihood.

max_log_posterior_index

The index of the sample with the highest log posterior.

max_log_posterior_sample

names

A list of names of unique priors in the same order as prior ids (and therefore sample columns)

number_live_points

parameter_lists

parameters_extract

paths

A list of paths to unique priors in the same order as prior ids (and therefore sample columns)

pdf_converged

To analyse and visualize samples the analysis must be sufficiently converged to produce smooth enough PDF for error estimate and PDF generation.

prior_means

The mean of every parameter used to link its inferred values and errors to priors used to sample the same (or similar) parameters in a subsequent search, where:

time

total_accepted_samples

The total number of accepted samples performed by the nested sampler.

total_iterations

total_samples

unconverged_sample_size

If a set of samples are unconverged, alternative methods to compute their means, errors, etc are used.

weight_list

__add__(other: SamplesNest) SamplesNest[source]#

Samples can be added together, which combines their sample_list meaning that inferred parameters are computed via their joint PDF.

Parameters:

other – Another Samples class

Return type:

A class that combined the samples of the two Samples objects.

property total_accepted_samples: int#

The total number of accepted samples performed by the nested sampler.

property acceptance_ratio: float#

The ratio of accepted samples to total samples.

samples_within_parameter_range(parameter_index: int, parameter_range: [<class 'float'>, <class 'float'>]) SamplesStored[source]#

Returns a new set of Samples where all points without parameter values inside a specified range removed.

For example, if our Samples object was for a model with 4 parameters are consistent of the following 3 sets of parameters:

[[1.0, 2.0, 3.0, 4.0]] [[100.0, 2.0, 3.0, 4.0]] [[1.0, 2.0, 3.0, 4.0]]

This function for parameter_index=0 and parameter_range=[0.0, 99.0] would remove the second sample because the value 100.0 is outside the range 0.0 -> 99.0.

Parameters:
  • parameter_index – The 1D index of the parameter (in the model’s vector representation) whose values lie between the parameter range if a sample is kept.

  • parameter_range – The minimum and maximum values of the range of parameter values this parameter must lie between for it to be kept.