gphist.posterior module

Expansion history posterior applied to distance functions.

class gphist.posterior.BAOPosterior(name, zpost, apar, sigma_apar, aperp, sigma_aperp, rho, rsdrag)

Bases: gphist.posterior.Posterior

Posterior constraint on the parallel and perpendicular scale factors from BAO.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (double) – Redshift where posterior should be evaluated.
  • apar (double) – Line-of-sight (parallel) scale factor measured using BAO.
  • sigma_apar (double) – RMS error on measured apar.
  • aperp (double) – Transverse (perpendicular) scale factor measured using BAO.
  • sigma_aperp (double) – RMS error on measured aperp.
  • rho (double) – Correlation coefficient between apar and aperp. Must be between -1 and +1.
Raises:

AssertionError – The redshift z is not an element of zprior.

constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

The posterior is applied simultaneously to DH(z)/rs(zd) and DA(z)/rs(zd).

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use.
  • DAz (ndarray) – Array of DA(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.BOSS2016Posterior(name, zpost, mean, cov, rsdrag)

Bases: gphist.posterior.Posterior

Posterior constraint on DH, DA for LRGs.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
  • mean (float) – data.
  • cov (float) – cavariance matrix.
  • rsdrag (float) – fiducial rsdrag.
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use.
  • DAz (ndarray) – Array of DA(zpost) values to use.
  • muz (ndarray) – this is no longer the 5log(DL/10pc) but instead 5 log (DL/DH0)
  • aparz (ndarray) – Array of apar(zpost) values to use.
  • aperpz (ndarray) – Array of aperp(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.CMBPosterior(name, zpost, DH, DA1pz, cov11, cov12, cov22)

Bases: gphist.posterior.Posterior

Posterior constraint on DH(zref) and DA(zref) from CMB with zpost ~ z*.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift where posterior should be evaluated.
  • DH (float) – Value of DH(zref) at zref=evol.zvalues[-1].
  • DA1pz (float) – Value of DA(zref)/(1+zref) at zref=evol.zvalues[-1].
  • cov11 (float) – Variance of DH(zref).
  • cov12 (float) – Covariance of DH(zref) and DA(zref)/(1+zref).
  • cov22 (float) – Variance of DA(zref)/(1+zref).
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use.
  • DAz (ndarray) – Array of DA(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.DAPosterior(name, zpost, DA, DA_error)

Bases: gphist.posterior.Posterior

Posterior constraint on DA(z).

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
  • DA (float) – Central value of DA(z).
  • DA_error (float) – RMS error on DA(z).
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use (will be ignored).
  • DAz (ndarray) – Array of DA(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.DESIPosterior(name, zpost, mean, cov, rsdrag)

Bases: gphist.posterior.Posterior

Posterior constraint on DH, DA for LRGs.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
  • mean (float) – data.
  • cov (float) – cavariance matrix.
  • rsdrag (float) – fiducial rsdrag.
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use.
  • DAz (ndarray) – Array of DA(zpost) values to use.
  • muz (ndarray) – this is no longer the 5log(DL/10pc) but instead 5 log (DL/DH0)
  • aparz (ndarray) – Array of apar(zpost) values to use.
  • aperpz (ndarray) – Array of aperp(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.DHPosterior(name, zpost, DH, DH_error)

Bases: gphist.posterior.Posterior

Posterior constraint on DH(z).

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
  • DH (float) – Central value of DH(z).
  • DH_error (float) – RMS error on DH(z).
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use.
  • DAz (ndarray) – Array of DA(zpost) values to use (will be ignored).
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.GaussianPdf(mean, covariance)

Bases: object

Represents a multi-dimensional Gaussian probability density function.

Parameters:
  • mean (ndarray) – 1D array of length npar of mean values.
  • covariance (ndarray) – 2D symmetric positive definite covariance matrix of shape (npar,npar).
Raises:
  • ValueError – dimensions of mean and covariance are incompatible.
  • LinAlgError – covariance matrix is not positive definite.
get_nlp(values)

Calculates -log(prob) for the PDF evaluated at specified values.

The calculation is automatically broadcast over multiple value vectors.

Parameters:
  • values (ndarray) – Array of values where the PDF should be evaluated with shape (neval,ndim) where ndim is the dimensionality of the PDF and neval is the number of points where the PDF should be evaluated.
  • precisely, it has shape (more) –
  • is the number of samples requested (nsamples) –
  • is the number of types of posteriors, types being DH, DA or mu (ntype) –
  • is the number of redshifts in a given posterior (nzposterior) –
Returns:

Array of length neval -log(prob) values calculated at each input point.

Return type:

float

Raises:

ValueError – Values can not be broadcast together with our mean vector.

class gphist.posterior.GaussianPdf1D(central_value, sigma)

Bases: gphist.posterior.GaussianPdf

Represents a specialization of GaussianPdf to the 1D case.

Parameters:
  • central_value (float) – Central value of the 1D PDF.
  • sigma (float) – RMS spread of the 1D PDF.
get_nlp(values)

Calculates -log(prob) for the PDF evaluated at specified values.

Parameters:values (ndarray) – Array of values where the PDF should be evaluated with length neval.
Returns:Array of length neval -log(prob) values calculated at each input point.
Return type:float
class gphist.posterior.GaussianPdf2D(x1, sigma1, x2, sigma2, rho12)

Bases: gphist.posterior.GaussianPdf

Represents a specialization of GaussianPdf to the 2D case.

Parameters:
  • x1 (float) – Central value of the first parameter.
  • x2 (float) – Central value of the second parameter.
  • sigma1 (float) – RMS spread of the first parameter.
  • sigma2 (float) – RMS spread of the second parameter.
  • rho12 (float) – Correlation coefficient between the two parameters. Must be between -1 and +1.
class gphist.posterior.LocalH0Posterior(name, H0, H0_error)

Bases: gphist.posterior.Posterior

Posterior constraint on the value of H0 determined from local measurements.

Parameters:
  • name (str) – Name to associate with this posterior.
  • H0 (float) – Central value of H(z=0).
  • H0_error (float) – RMS error on H(z=0).
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

The posterior is applied to c/H(z=0).

DHz(ndarray): Array of DH(z=0) values to use. DAz(ndarray): Array of DA(z=0) values to use (will be ignored).
Returns:Array of -log(prob) values calculated at each input value.
Return type:ndarray
class gphist.posterior.Posterior(name, zpost)

Bases: object

Posterior constraint on DH,DA at a fixed redshift.

This is an abstract base class and subclasses must implement the constraint method.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
constraint(DHz, DAz, muz, aparz, aperpz)

Evaluate the posterior constraint given values of DH(zpost) and DA(zpost).

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values.
  • DAz (ndarray) – Array of DA(zpost) values with the same shape as DHz.
Returns:

Array of -log(prob) values with the same shape as DHz and DAz.

Return type:

nlp(ndarray)

get_nlp(zprior, DH, DA, mu, apar, aperp)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

The posterior is applied to c/H(z=0).

zprior(ndarray): Redshifts where prior is sampled, in increasing order. DH(ndarray): Array of shape (nsamples,nz) of DH(z) values to use. DA(ndarray): Array of shape (nsamples,nz) of DA(z) values to use.
Returns:Array of -log(prob) values calculated at each input value.
Return type:ndarray
Raises:AssertionError – zpost is not in zprior.
class gphist.posterior.SNPosterior(name, zpost, mu, mu_error)

Bases: gphist.posterior.Posterior

Posterior constraint on mu(z).

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
  • mu (float) – Central value of mu*(z): actually mu(z)-(M_1=19.05).
  • mu_error (float) – RMS error on mu(z).
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use (will be ignored).
  • DAz (ndarray) – Array of DA(zpost) values to use (also ignored).
  • muz (ndarray) – this is no longer the 5log(DL/10pc) but instead 5 log (DL/DH0)
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.ScalePosteriorLRG(name, zpost, mean, cov, rsdrag)

Bases: gphist.posterior.Posterior

Posterior constraint on DH, DA for LRGs.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (float) – Redshift of posterior constraint.
  • mean (float) – data.
  • cov (float) – cavariance matrix.
  • rsdrag (float) – fiducial rsdrag.
constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

Parameters:
  • DHz (ndarray) – Array of DH(zpost) values to use.
  • DAz (ndarray) – Array of DA(zpost) values to use.
  • muz (ndarray) – this is no longer the 5log(DL/10pc) but instead 5 log (DL/DH0)
  • aparz (ndarray) – Array of apar(zpost) values to use.
  • aperpz (ndarray) – Array of aperp(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray

class gphist.posterior.ScalePosteriorLya(name, zpost, apar, sigma_apar, aperp, sigma_aperp, rho, rsdrag)

Bases: gphist.posterior.Posterior

Posterior constraint on the parallel and perpendicular scale factors from BAO.

Parameters:
  • name (str) – Name to associate with this posterior.
  • zpost (double) – Redshift where posterior should be evaluated.
  • apar (double) – Line-of-sight (parallel) scale factor measured using BAO.
  • sigma_apar (double) – RMS error on measured apar.
  • aperp (double) – Transverse (perpendicular) scale factor measured using BAO.
  • sigma_aperp (double) – RMS error on measured aperp.
  • rho (double) – Correlation coefficient between apar and aperp. Must be between -1 and +1.
Raises:

AssertionError – The redshift z is not an element of zprior.

constraint(DHz, DAz, muz, aparz, aperpz)

Calculate -log(prob) for the posterior applied to a set of expansion histories.

The posterior is applied simultaneously to DH(z)/rs(zd) and DA(z)/rs(zd).

Parameters:
  • aparz (ndarray) – Array of apar(zpost) values to use.
  • aperpz (ndarray) – Array of aperp(zpost) values to use.
Returns:

Array of -log(prob) values calculated at each input value.

Return type:

ndarray