# getdist.mcsamples¶

getdist.mcsamples.loadMCSamples(file_root, ini=None, jobItem=None, no_cache=False, settings={}, dist_settings={})[source]

Loads a set of samples from a file or files.

Sample files are plain text (file_root.txt) or a set of files (file_root_1.txt, file_root_2.txt, etc.).

Auxiliary files file_root.paramnames gives the parameter names and (optionally) file_root.ranges gives hard prior parameter ranges.

For a description of the various analysis settings and default values see analysis_defaults.ini.

Parameters: file_root – The root name of the files to read (no extension) ini – The name of a .ini file with analysis settings to use jobItem – an optional grid jobItem instance for a CosmoMC grid output no_cache – Indicates whether or not we should cache loaded samples in a pickle settings – dictionary of analysis settings to override defaults dist_settings – (old) alias for settings The MCSamples instance
class getdist.mcsamples.MCSamples(root=None, jobItem=None, ini=None, settings=None, ranges=None, samples=None, weights=None, loglikes=None, **kwargs)[source]

The main high-level class for a collection of parameter samples.

Derives from chains.Chains, adding high-level functions including Kernel Density estimates, parameter ranges and custom settings.

For a description of the various analysis settings and default values see analysis_defaults.ini.

Parameters: root – A root file name when loading from file jobItem – Optional paramgrid.batchjob.jobItem instance if a member of a parameter grid ini – a .ini file to use for custom analysis settings settings – a dictionary of custom analysis settings ranges – a dictionary giving any additional hard prior bounds for parameters, eg. {‘x’:[0, 1], ‘y’:[None,2]} samples – if not loading from file, array of parameter values for each sample, passed to setSamples(), or list of arrays if more than one chain weights – array of weights for samples, or list of arrays if more than one chain loglikes – array of -log(Likelihood) for samples, or list of arrays if more than one chain kwargs – keyword arguments passed to inherited classes, e.g. to manually make a samples object from sample arrays in memory: paramNamesFile: optional name of .paramnames file with parameter names names: list of names for the parameters, or list of arrays if more than one chain labels: list of latex labels for the parameters renames: dictionary of parameter aliases ignore_rows: if int >=1: The number of rows to skip at the file in the beginning of the file if float <1: The fraction of rows to skip at the beginning of the file name_tag: a name tag for this instance
PCA(params, param_map=None, normparam=None, writeDataToFile=False, filename=None, conditional_params=[], n_best_only=None)[source]

Perform principle component analysis (PCA). In other words, get eigenvectors and eigenvalues for normalized variables with optional (log modulus) mapping to find power law fits.

Parameters: params – List of names of the parameters to use param_map – A transformation to apply to parameter values; A list or string containing either N (no transformation) or L (for log transform) for each parameter. By default uses log if no parameter values cross zero normparam – optional name of parameter to normalize result (i.e. this parameter will have unit power) writeDataToFile – True if should write the output to file. filename – The filename to write, by default root_name.PCA. conditional_params – optional list of parameters to treat as fixed, i.e. for PCA conditional on fixed values of these parameters n_best_only – return just the short summary constraint for the tightest n_best_only constraints a string description of the output of the PCA
addDerived(paramVec, name, label='', comment='', range=None)[source]

Parameters: paramVec – The vector of parameter values to add. For example a combination of parameter arrays from MCSamples.getParams() name – The name for the new parameter label – optional latex label for the parameter comment – optional comment describing the parameter range – if specified, a tuple of min, max values for the new parameter hard prior bounds (either can be None for one-side bound) The added parameter’s ParamInfo object
changeSamples(samples)

Sets the samples without changing weights and loglikes.

Parameters: samples – The samples to set
confidence(paramVec, limfrac, upper=False, start=0, end=None, weights=None)

Calculate sample confidence limits, not using kernel densities just counting samples in the tails

Parameters: paramVec – array of parameter values or int index of parameter to use limfrac – fraction of samples in the tail, e.g. 0.05 for a 95% one-tail limit, or 0.025 for a 95% two-tail limit upper – True to get upper limit, False for lower limit start – Start index for the vector to use end – The end index, use None to go all the way to the end of the vector. weights – numpy array of weights for each sample, by default self.weights confidence limit (parameter value when limfac of samples are further in the tail)
cool(cool)

Cools the samples, i.e. multiples log likelihoods by cool factor and re-weights accordingly

Parameters: cool – cool factor
corr(pars=None)

Get the correlation matrix

Parameters: pars – If specified, list of parameter vectors or int indices to use The correlation matrix.
cov(pars=None, where=None)

Get parameter covariance

Parameters: pars – if specified, a list of parameter vectors or int indices to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). The covariance matrix
deleteFixedParams()

Delete parameters that are fixed (the same value in all samples)

deleteZeros()

Removes samples with zero weight

filter(where)

Filter the stored samples to keep only samples matching filter

Parameters: where – list of sample indices to keep, or boolean array filter (e.g. x>5 to keep only samples where x>5)
get1DDensity(name, **kwargs)[source]

Returns a Density1D instance for parameter with given name. Result is cached.

Parameters: name – name of the parameter kwargs – arguments for get1DDensityGridData() A Density1D instance for parameter with given name
get1DDensityGridData(j, writeDataToFile=False, get_density=False, paramConfid=None, meanlikes=False, **kwargs)[source]

Low-level function to get a Density1D instance for the marginalized 1D density of a parameter. Result is not cached.

Parameters: j – a name or index of the parameter writeDataToFile – True if should write to text file. get_density – return a Density1D instance only, does not write out or calculate mean likelihoods for plots paramConfid – optional cached ParamConfidenceData instance meanlikes – include mean likelihoods kwargs – optional settings to override instance settings of the same name (see analysis_settings): smooth_scale_1D boundary_correction_order mult_bias_correction_order fine_bins num_bins A Density1D instance
get2DDensity(x, y, normalized=False, **kwargs)[source]

Returns a Density2D instance with marginalized 2D density.

Parameters: x – index or name of x parameter y – index or name of y parameter kwargs – keyword arguments for the get2DDensityGridData() function normalized – if False, is normalized so the maximum is 1, if True, density is normalized Density2D instance
get2DDensityGridData(j, j2, writeDataToFile=False, num_plot_contours=None, get_density=False, meanlikes=False, **kwargs)[source]

Low-level function to get 2D plot marginalized density and optional additional plot data.

Parameters: j – name or index of the x parameter j2 – name or index of the y parameter. writeDataToFile – True if should write data to file num_plot_contours – number of contours to calculate and return in density.contours get_density – only get the 2D marginalized density, no additional plot data meanlikes – calculate mean likelihoods as well as marginalized density (returned as array in density.likes) kwargs – optional settings to override instance settings of the same name (see analysis_settings): fine_bins_2D boundary_correction_order mult_bias_correction_order smooth_scale_2D a Density2D instance
getAutoBandwidth1D(bins, par, param, mult_bias_correction_order=None, kernel_order=1, N_eff=None)[source]

Get optimized kernel density bandwidth (in units of the range of the bins) Based on optimal Improved Sheather-Jones bandwidth for basic Parzen kernel, then scaled if higher-order method being used. For details see the notes.

Parameters: bins – numpy array of binned weights for the samples par – A ParamInfo instance for the parameter to analyse param – index of the parameter to use mult_bias_correction_order – order of multiplicative bias correction (0 is basic Parzen kernel); by default taken from instance settings. kernel_order – order of the kernel (0 is Parzen, 1 does linear boundary correction, 2 is a higher-order kernel) N_eff – effective number of samples. If not specified estimated using weights, autocorrelations, and fiducial bandwidth kernel density bandwidth (in units the range of the bins)
getAutoBandwidth2D(bins, parx, pary, paramx, paramy, corr, rangex, rangey, base_fine_bins_2D, mult_bias_correction_order=None, min_corr=0.2, N_eff=None)[source]

Get optimized kernel density bandwidth matrix in parameter units, using Improved Sheather Jones method in sheared parameters. For details see the notes.

Parameters: bins – 2D numpy array of binned weights parx – A ParamInfo instance for the x parameter pary – A ParamInfo instance for the y parameter paramx – index of the x parameter paramy – index of the y parameter corr – correlation of the samples rangex – scale in the x parameter rangey – scale in the y parameter base_fine_bins_2D – number of bins to use for re-binning in rotated parameter space mult_bias_correction_order – multiplicative bias correction order (0 is Parzen kernel); by default taken from instance settings min_corr – minimum correlation value at which to bother de-correlating the parameters N_eff – effective number of samples. If not specified, currently uses crude estimate from effective numbers in x and y separately kernel density bandwidth matrix in parameter units
getAutocorrelation(paramVec, maxOff=None, weight_units=True, normalized=True)

Gets auto-correlation of an array of parameter values (e.g. for correlated samples from MCMC)

By default uses weight units (i.e. standard units for separate samples from original chain). If samples are made from multiple chains, neglects edge effects.

Parameters: paramVec – an array of parameter values, or the int index of the parameter in stored samples to use maxOff – maximum autocorrelation distance to return weight_units – False to get result in sample point (row) units; weight_units=False gives standard definition for raw chains normalized – Set to False to get covariance (note even if normalized, corr[0]<>1 in general unless weights are unity). zero-based array giving auto-correlations
getBounds()[source]

Returns the bounds in the form of a ParamBounds instance, for example for determining plot ranges

Bounds are not the same as self.ranges, as if samples are not near the range boundary, the bound is set to None

Returns: a ParamBounds instance
getCombinedSamplesWithSamples(samps2, sample_weights=[1, 1])[source]

Make a new MCSamples instance by appending samples from samps2 for parameters which are in common. By default they are weighted so that the probability mass of each set of samples is the same, independent of tha actual sample sizes. The Weights parameter can be adjusted to change the relative weighting. :param samps2: MCSamples instance to merge :param sample_weights: relative weights for combining the samples. Set to None to just directly append samples. :return: a new MCSamples instance with the combined samples

getConvergeTests(test_confidence=0.95, writeDataToFile=False, what=['MeanVar', 'GelmanRubin', 'SplitTest', 'RafteryLewis', 'CorrLengths'], filename=None, feedback=False)[source]

Do convergence tests.

Parameters: test_confidence – confidence limit to test for convergence (two-tail, only applies to some tests) writeDataToFile – True if should write output to a file what – The tests to run. Should be a list of any of the following: ’MeanVar’: Gelman-Rubin sqrt(var(chain mean)/mean(chain var)) test in individual parameters (multiple chains only) ’GelmanRubin’: Gelman-Rubin test for the worst orthogonalized parameter (multiple chains only) ’SplitTest’: Crude test for variation in confidence limits when samples are split up into subsets ’RafteryLewis’: Raftery-Lewis test (integer weight samples only) ’CorrLengths’: Sample correlation lengths filename – The filename to write to, default is file_root.converge feedback – If set to True, Prints the output as well as returning it. text giving the output of the tests
getCorrelatedVariable2DPlots(num_plots=12, nparam=None)[source]

Gets a list of most correlated variable pair names.

Parameters: num_plots – The number of plots nparam – maximum number of pairs to get list of [x,y] pair names
getCorrelationLength(j, weight_units=True, min_corr=0.05, corr=None)

Gets the auto-correlation length for parameter j

Parameters: j – The index of the parameter to use weight_units – False to get result in sample point (row) units; weight_units=False gives standard definition for raw chains min_corr – specifies a minimum value of the autocorrelation to use, e.g. where sampling noise is typically as large as the calculation corr – The auto-correlation array to use, calculated internally by default using getAutocorrelation() the auto-correlation length
getCorrelationMatrix()

Get the correlation matrix of all parameters

Returns: The correlation matrix
getCov(nparam=None, pars=None)

Get covariance matrix of the parameters. By default uses all parameters, or can limit to max number or list.

Parameters: nparam – if specified, only use the first nparam parameters pars – if specified, a list of parameter indices (0,1,2..) to include covariance matrix.
getCovMat()[source]

Gets the CovMat instance containing covariance matrix for all the non-derived parameters (for example useful for subsequent MCMC runs to orthogonalize the parameters)

Returns: A CovMat object holding the covariance
getEffectiveSamples(j=0, min_corr=0.05)

Gets effective number of samples N_eff so that the error on mean of parameter j is sigma_j/N_eff

Parameters: j – The index of the param to use. min_corr – the minimum value of the auto-correlation to use when estimating the correlation length
getEffectiveSamplesGaussianKDE(paramVec, h=0.2, scale=None, maxoff=None, min_corr=0.05)

Roughly estimate an effective sample number for use in the leading term for the MISE (mean integrated squared error) of a Gaussian-kernel KDE (Kernel Density Estimate). This is used for optimizing the kernel bandwidth, and though approximate should be better than entirely ignoring samples correlations, or only counting distinct samples.

Uses fiducial assumed kernel scale h; result does depend on this (typically by factors O(2))

For bias-corrected KDE only need very rough estimate to use in rule of thumb for bandwidth.

In the limit h-> 0 (but still >0) answer should be correct (then just includes MCMC rejection duplicates). In reality correct result for practical h should depends on shape of the correlation function.

If self.sampler is ‘nested’ or ‘uncorrelated’ return result for uncorrelated samples

Parameters: paramVec – parameter array, or int index of parameter to use h – fiducial assumed kernel scale. scale – a scale parameter to determine fiducial kernel width, by default the parameter standard deviation maxoff – maximum value of auto-correlation length to use min_corr – ignore correlations smaller than this auto-correlation A very rough effective sample number for leading term for the MISE of a Gaussian KDE.
getFractionIndices(weights, n)[source]

Calculates the indices of weights that split the weights into sets of equal 1/n fraction of the total weight

Parameters: weights – array of weights n – number of groups to split in to array of indices of the boundary rows in the weights array
getGelmanRubin(nparam=None, chainlist=None)

Assess the convergence using the maximum var(mean)/mean(var) of orthogonalized parameters c.f. Brooks and Gelman 1997.

Parameters: nparam – The number of parameters, by default uses all chainlist – list of WeightedSamples, the samples to use. Defaults to all the separate chains in this instance. The worst var(mean)/mean(var) for orthogonalized parameters. Should be <<1 for good convergence.
getGelmanRubinEigenvalues(nparam=None, chainlist=None)

Assess convergence using var(mean)/mean(var) in the orthogonalized parameters c.f. Brooks and Gelman 1997.

Parameters: nparam – The number of parameters (starting at first), by default uses all of them chainlist – list of WeightedSamples, the samples to use. Defaults to all the separate chains in this instance. array of var(mean)/mean(var) for orthogonalized parameters
getInlineLatex(param, limit=1, err_sig_figs=None)[source]

Get snippet like: A=x\pm y. Will adjust appropriately for one and two tail limits.

Parameters: param – The name of the parameter limit – which limit to get, 1 is the first (default 68%), 2 is the second (limits array specified by self.contours) err_sig_figs – significant figures in the error The tex snippet.
getLabel()

Return the latex label for the samples

Returns: the label
getLatex(params=None, limit=1, err_sig_figs=None)[source]

Get tex snippet for constraints on a list of parameters

Parameters: params – list of parameter names, or a single parameter name limit – which limit to get, 1 is the first (default 68%), 2 is the second (limits array specified by self.contours) err_sig_figs – significant figures in the error labels, texs: a list of parameter labels, and a list of tex snippets, or for a single parameter, the latex snippet.
getLikeStats()[source]

Get best fit sample and n-D confidence limits, and various likelihood based statistics

Returns: a LikeStats instance storing N-D limits for parameter i in result.names[i].ND_limit_top, result.names[i].ND_limit_bot, and best-fit sample value in result.names[i].bestfit_sample
getLower(name)[source]

Return the lower limit of the parameter with the given name.

Parameters: name – parameter name The lower limit if name exists, None otherwise.
getMargeStats(include_bestfit=False)[source]

Returns a MargeStats object with marginalized 1D parameter constraints

Parameters: include_bestfit – if True, set best fit values by loading from root_name.minimum file (assuming it exists) A MargeStats instance
getMeans()

Gets the parameter means, from saved array if previously calculated.

Returns: numpy array of parameter means
getName()

Returns the name tag of these samples.

Returns: The name tag
getNumSampleSummaryText()[source]

Returns a summary text describing numbers of parameters and samples, and various measures of the effective numbers of samples.

Returns: The summary text as a string.
getParamBestFitDict()[source]

Gets a dictionary of parameter values for the best fit point, assuming .minimum best fit file exists :return: dictionary of parameter values

getParamNames()

Get ParamNames object with names for the parameters

Returns: ParamNames object giving parameter names and labels
getParamSampleDict(ix)[source]

Gets a dictionary of parameter values for sample number ix :return: dictionary of parameter values

getParams()

Creates a ParSamples object, with variables giving vectors for all the parameters, for example samples.getParams().name1 would be the vector of samples with name ‘name1’

Returns: A ParSamples object containing all the parameter vectors, with attributes given by the parameter names
getRawNDDensity(xs, normalized=False, **kwargs)[source]

Returns a DensityND instance with marginalized ND density.

Parameters: xs – indices or names of x_i parameters kwargs – keyword arguments for the getRawNDDensityGridData() function normalized – if False, is normalized so the maximum is 1, if True, density is normalized DensityND instance
getRawNDDensityGridData(js, writeDataToFile=False, num_plot_contours=None, get_density=False, meanlikes=False, maxlikes=False, **kwargs)[source]

Low-level function to get unsmooth ND plot marginalized density and optional additional plot data.

Parameters: js – vector of names or indices of the x_i parameters writeDataToFile – True if should write data to file num_plot_contours – number of contours to calculate and return in density.contours get_density – only get the ND marginalized density, no additional plot data, no contours. meanlikes – calculate mean likelihoods as well as marginalized density (returned as array in density.likes) maxlikes – calculate the profile likelihoods in addition to the others (returned as array in density.maxlikes) kwargs – optional settings to override instance settings of the same name (see analysis_settings): a DensityND instance
getRenames()

Updates the renames known to each parameter with the given dictionary of renames.

getSeparateChains()

Gets a list of samples for separate chains. If the chains have already been combined, uses the stored sample offsets to reconstruct the array (generally no array copying)

Returns: The list of WeightedSamples for each chain.
getSignalToNoise(params, noise=None, R=None, eigs_only=False)

Returns w, M, where w is the eigenvalues of the signal to noise (small means better constrained)

Parameters: params – list of parameters indices to use noise – noise matrix R – rotation matrix, defaults to inverse of Cholesky root of the noise matrix eigs_only – only return eigenvalues w, M, where w is the eigenvalues of the signal to noise (small means better constrained)
getTable(columns=1, include_bestfit=False, **kwargs)[source]

Creates and returns a ResultTable instance. See also getInlineLatex().

Parameters: columns – number of columns in the table include_bestfit – True if should include the bestfit parameter values (assuming set) kwargs – arguments for ResultTable constructor. A ResultTable instance
getUpper(name)[source]

Return the upper limit of the parameter with the given name.

Parameters: name – parameter name The upper limit if name exists, None otherwise.
getVars()

Get the parameter variances

Returns: A numpy array of variances.
get_norm(where=None)

gets the normalization, the sum of the sample weights: sum_i w_i

Parameters: where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). normalization
initParamConfidenceData(paramVec, start=0, end=None, weights=None)

Initialize cache of data for calculating confidence intervals

Parameters: paramVec – array of parameter values or int index of parameter to use start – The sample start index to use end – The sample end index to use, use None to go all the way to the end of the vector weights – A numpy array of weights for each sample, defaults to self.weights ParamConfidenceData instance
initParameters(ini)[source]

Initializes settings. Gets parameters from IniFile.

Parameters: ini – The IniFile to be used
loadChains(root, files_or_samples, weights=None, loglikes=None, ignore_lines=None)

Parameters: root – Root name files_or_samples – list of file names or list of arrays of samples, or single array of samples weights – if loading from arrays of samples, corresponding list of arrays of weights loglikes – if loading from arrays of samples, corresponding list of arrays of -2 log(likelihood) ignore_lines – Amount of lines at the start of the file to ignore, None if should not ignore True if loaded successfully, False if none loaded
makeSingle()

Combines separate chains into one samples array, so self.samples has all the samples and this instance can then be used as a general WeightedSamples instance.

Returns: self
makeSingleSamples(filename='', single_thin=None)[source]

Make file of weight-1 samples by choosing samples with probability given by their weight.

Parameters: filename – The filename to write to, leave empty if no output file is needed single_thin – factor to thin by; if not set generates as many samples as it can up to self.max_scatter_points numpy array of selected weight-1 samples
mean(paramVec, where=None)

Get the mean of the given parameter vector.

Parameters: paramVec – array of parameter values or int index of parameter to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). parameter mean
mean_diff(paramVec, where=None)

Calculates an array of differences between a parameter vector and the mean parameter value

Parameters: paramVec – array of parameter values or int index of parameter to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). array of p_i - mean(p_i)
mean_diffs(pars=None, where=None)

Calculates a list of parameter vectors giving distances from parameter means

Parameters: pars – if specified, list of parameter vectors or int parameter indices to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). list of arrays p_i-mean(p-i) for each parameter
parLabel(i)[source]

Gets the latex label of the parameter

Parameters: i – The index or name of a parameter. The parameter’s label.
parName(i, starDerived=False)[source]

Gets the name of i’th parameter

Parameters: i – The index of the parameter starDerived – add a star at the end of the name if the parameter is derived The name of the parameter (string)
randomSingleSamples_indices()

Returns an array of sample indices that give a list of weight-one samples, by randomly selecting samples depending on the sample weights

Returns: array of sample indices
readChains(files_or_samples, weights=None, loglikes=None)[source]

Loads samples from a list of files or array(s), removing burn in, deleting fixed parameters, and combining into one self.samples array

Parameters: files_or_samples – The list of file names to read, samples or list of samples weights – array of weights if setting from arrays loglikes – array of -2 log(likelihood) if setting from arrays self.
removeBurn(remove=0.3)

removes burn in from the start of the samples

Parameters: remove – fraction of samples to remove, or if int >1, the number of sample rows to remove
removeBurnFraction(ignore_frac)

Remove a fraction of the samples as burn in

Parameters: ignore_frac – fraction of sample points to remove from the start of the samples, or each chain if not combined
reweightAddingLogLikes(logLikes)

Importance sample the samples, by adding logLike (array of -log(likelihood values) to the currently stored likelihoods, and re-weighting accordingly, e.g. for adding a new data constraint

Parameters: logLikes – array of -log(likelihood) for each sample to adjust
saveAsText(root, chain_index=None, make_dirs=False)[source]

Saves samples as text file, including .ranges and .paramnames.

Parameters: root – The root file name to use. chain_index – optional index to be used for the filename. make_dirs – True if should create the directories
savePickle(filename)

Save the current object to a file in pickle format

Parameters: filename – The file to write to
setColData(coldata, are_chains=True)

Set the samples given an array loaded from file

Parameters: coldata – The array with columns of [weights, -log(Likelihoods)] and sample parameter values are_chains – True if coldata starts with two columns giving weight and -log(Likelihood)
setDiffs()

saves self.diffs array of parameter differences from the means, e.g. to later calculate variances etc.

Returns: array of differences
setMeans()

Calculates and saves the means for the samples

Returns: numpy array of parameter means
setMinWeightRatio(min_weight_ratio=1e-30)

Removes samples with weight less than min_weight_ratio times the maximum weight

Parameters: min_weight_ratio – minimum ratio to max to exclude
setParamNames(names=None)

Sets the names of the params.

Parameters: names – Either a ParamNames object, the name of a .paramnames file to load, a list of name strings, otherwise use default names (param1, param2…).
setParams(obj)

Adds array variables obj.name1, obj.name2 etc, where obj.name1 is the vector of samples with name ‘name1’

if a parameter name is of the form aa.bb.cc, it makes subobjects so you can reference obj.aa.bb.cc

Parameters: obj – The object instance to add the parameter vectors variables The obj after alterations.
setRanges(ranges)[source]

Sets the ranges parameters, e.g. hard priors on positivity etc. If a min or max value is None, then it is assumed to be unbounded.

Parameters: ranges – A list or a tuple of [min,max] values for each parameter, or a dictionary giving [min,max] values for specific parameter names
setSamples(samples, weights=None, loglikes=None, min_weight_ratio=None)

Sets the samples from numpy arrays

Parameters: samples – The samples values, n_samples x n_parameters numpy array, or can be a list of parameter vectors weights – Array of weights for each sample. Defaults to 1 for all samples if unspecified. loglikes – Array of -log(Likelihood) values for each sample min_weight_ratio – remove samples with weight less than min_weight_ratio of the maximum
std(paramVec, where=None)

Get the standard deviation of the given parameter vector.

Parameters: paramVec – array of parameter values or int index of parameter to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). parameter standard deviation.
thin(factor)

Thin the samples by the given factor, giving set of samples with unit weight

Parameters: factor – The factor to thin by
thin_indices(factor, weights=None)

Indices to make single weight 1 samples. Assumes integer weights.

Parameters: factor – The factor to thin by, should be int. weights – The weights to thin, None if this should use the weights stored in the object. array of indices of samples to keep
twoTailLimits(paramVec, confidence)

Calculates two-tail equal-area confidence limit by counting samples in the tails

Parameters: paramVec – array of parameter values or int index of parameter to use confidence – confidence limit to calculate, e.g. 0.95 for 95% confidence min, max values for the confidence interval
updateBaseStatistics()[source]

Updates basic computed statistics (means, covariance etc), e.g. after a change in samples or weights

Returns: self
updateRenames(renames)

Updates the renames known to each parameter with the given dictionary of renames.

updateSettings(settings=None, ini=None, doUpdate=True)[source]

Updates settings from a .ini file or dictionary

Parameters: settings – The a dict containing settings to set, taking preference over any values in ini ini – The name of .ini file to get settings from, or an IniFile instance; by default uses current settings doUpdate – True if should update internal computed values, False otherwise (e.g. if want to make other changes first)
var(paramVec, where=None)

Get the variance of the given parameter vector.

Parameters: paramVec – array of parameter values or int index of parameter to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). parameter variance
weighted_sum(paramVec, where=None)

Calculates the weighted sum of a parameter vector, sum_i w_i p_i

Parameters: paramVec – array of parameter values or int index of parameter to use where – if specified, a filter for the samples to use (where x>=5 would mean only process samples with x>=5). weighted sum
writeCorrelationMatrix(filename=None)[source]

Write the correlation matrix to a file

Parameters: filename – The file to write to, If none writes to file_root.corr
writeCovMatrix(filename=None)[source]

Writes the covrariance matrix of non-derived parameters to a file.

Parameters: filename – The filename to write to; default is file_root.covmat
writeScriptPlots1D(filename, plotparams=None, ext=None)[source]

Write a script that generates a 1D plot. Only intended for use by GetDist.py script.

Parameters: filename – The filename to write to. plotparams – The list of parameters to plot (default: all) ext – The extension for the filename, Default if None
writeScriptPlots2D(filename, plot_2D_param=None, cust2DPlots=[], writeDataToFile=False, ext=None, shade_meanlikes=False)[source]

Write script that generates a 2 dimensional plot. Only intended for use by GetDist.py script.

Parameters: filename – The filename to write to. plot_2D_param – parameter to plot other variables against cust2DPlots – list of parts of parameter names to plot writeDataToFile – True if should write to file ext – The extension for the filename, Default if None shade_meanlikes – shade by mean likelihoods A dictionary indexed by pairs of parameters where 2D densities have been calculated
writeScriptPlots3D(filename, plot_3D, ext=None)[source]

Writes a script that generates a 3D (coloured-scatter) plot. Only intended for use by GetDist.py script.

Parameters: filename – The filename to write to plot_3D – list of [x,y,z] parameters for the 3 Dimensional plots ext – The extension for the filename, Default if None
writeScriptPlotsTri(filename, triangle_params, ext=None)[source]

Write a script that generates a triangle plot. Only intended for use by GetDist.py script.

Parameters: filename – The filename to write to. triangle_params – list of parameter names to plot ext – The extension for the filename, Default if None
writeThinData(fname, thin_ix, cool=1)[source]

Writes samples at thin_ix to file

Parameters: fname – The filename to write to. thin_ix – Indices of the samples to write cool – if not 1, cools the samples by this factor
exception getdist.mcsamples.MCSamplesError[source]

An Exception that is raised when there is an error inside the MCSamples class.

exception getdist.mcsamples.ParamError[source]

An Exception that indicates a bad parameter.

exception getdist.mcsamples.SettingError[source]

An Exception that indicates bad settings.