pyCE.cosmology.analysis.mps module

Information-theoretic analysis of matter power spectra.

Continuum (integral) analogues of the discrete measures in pyCE.cosmology.analysis.aps: modal fractions, differential Shannon entropy, and Kullback-Leibler divergence for power spectra defined on a continuous wavenumber grid, with the d-dimensional Jacobian factor x**(d-1) included in the measure. All integrals use the trapezoidal rule.

pyCE.cosmology.analysis.mps.KL_divergence(x, p, q, xmin=0, xmax=inf)[source]

Kullback-Leibler divergence D(p || q) in bits.

Note that the divergence is not symmetric in its arguments. Only modes with xmin <= x <= xmax where both p and q are positive contribute.

Parameters:
  • x (ndarray) – Wavenumber grid.

  • p, q (ndarray) – Modal fractions sampled on x.

  • xmin, xmax (float, optional) – Bounds of the valid k-range.

Returns:

Integral[ p * log2(p/q) dx ] over the valid range.

Return type:

float

pyCE.cosmology.analysis.mps.entropy(x, p)[source]

Differential Shannon entropy of a modal fraction, in bits.

Parameters:
  • x (ndarray) – Wavenumber grid.

  • p (ndarray) – Modal fraction sampled on x.

Returns:

-Integral[ p * log2(p) dx ].

Return type:

float

pyCE.cosmology.analysis.mps.modal_fraction(x, y, d=3, xmax=inf, xmin=0)[source]

Modal fraction of a power spectrum over a restricted k-range.

Restricts to the modes with xmin <= x <= xmax and y > 0, normalizes the spectrum there with the d-dimensional measure, and attaches the Jacobian factor x**(d-1) so the result is a probability density in x.

Parameters:
  • x (ndarray) – Wavenumber grid.

  • y (ndarray) – Power spectrum sampled on x.

  • d (int, optional) – Number of spatial dimensions (default 3).

  • xmax, xmin (float, optional) – Bounds of the valid k-range.

Returns:

  • x (ndarray) – The valid wavenumbers.

  • mf (ndarray) – The modal fraction on those wavenumbers.

pyCE.cosmology.analysis.mps.norm(x, y, d=3)[source]

Normalize y over x with the d-dimensional radial measure.

Parameters:
  • x (ndarray) – Wavenumber grid.

  • y (ndarray) – Spectrum sampled on x.

  • d (int, optional) – Number of spatial dimensions (default 3).

Returns:

y divided by Integral[ y * x**(d-1) dx ].

Return type:

ndarray