getdist.densities

class getdist.densities.Density1D(x, P=None, view_ranges=None)[source]

Class for 1D marginalized densities, inheriting from GridDensity.

Parameters:
  • x – array of x values
  • P – array of densities at x values
  • view_ranges – optional range for viewing density
Prob(x, derivative=0)[source]

Calculate density at position x by interpolation in the density grid

Parameters:
  • x – x value
  • derivative – optional order of derivative to calculate (default: no derivative)
Returns:

P(x) density value

bounds()[source]

Get min, max bounds (from view_ranges if set)

getLimits(p, interpGrid=None, accuracy_factor=None)[source]

Get parameter equal-density confidence limits (a credible interval). If the density is bounded, may only have a one-tail limit.

Parameters:
  • p – list of limits to calculate, e.g. [0.68, 0.95]
  • interpGrid – optional pre-computed cache
  • accuracy_factor – parameter to boost default accuracy for fine sampling
Returns:

list of (min, max, has_min, has_top) values where has_min and has_top are True or False depending on whether lower and upper limit exists

class getdist.densities.Density2D(x, y, P=None, view_ranges=None)[source]

Class for 2D marginalized densities, inheriting from GridDensity and RectBivariateSpline.

Parameters:
  • x – array of x values
  • y – array of y values
  • P – 2D array of density values at x, y
  • view_ranges – optional ranges for viewing density
Prob(x, y)[source]

Evaluate density at x,y using interpolation

class getdist.densities.DensityND(xs, P=None, view_ranges=None)[source]

Class for ND marginalized densities, inheriting from GridDensity and LinearNDInterpolator.

Parameters:
  • xs – list of arrays of x values
  • P – ND array of density values at xs
  • view_ranges – optional ranges for viewing density
Prob(xs)[source]

Evaluate density at x,y,z using interpolation

class getdist.densities.GridDensity[source]

Base class for probability density grids (normalized or not)

Variables:P – array of density values
bounds()[source]

Get bounds in order x, y, z..

Returns:list of (min,max) values
getContourLevels(contours=[0.68, 0.95])[source]

Get contour levels

Parameters:contours – list of confidence limits to get (default [0.68, 0.95])
Returns:list of contour levels
normalize(by='integral', in_place=False)[source]

Normalize the density grid

Parameters:
  • by – ‘integral’ for standard normalization, or ‘max’, to normalize so the maximum value is unity
  • in_place – if True, normalize in place, otherwise make copy (in case self.P is used elsewhere)
setP(P=None)[source]

Set the density grid values

Parameters:P – numpy array of density values
getdist.densities.getContourLevels(inbins, contours=[0.68, 0.95], missing_norm=0, half_edge=True)[source]

Get contour levels enclosing “contours” fraction of the probability, for any dimension bins array

Parameters:
  • inbins – binned density.
  • contours – list of confidence contours to calculate, default [0.68, 0.95]
  • missing_norm – accounts of any points not included in inbins (e.g. points in far tails that are not in inbins)
  • half_edge – If True, edge bins are only half integrated over in each direction.
Returns:

list of density levels