Fisher forecast#
This notebook forecasts parameter constraints for a Euclid-like spectroscopic galaxy survey.
A Fisher forecast needs the derivative of the observable with respect to every parameter. Here the observable is the galaxy power spectrum in four redshift bins, with the Kaiser effect and the Alcock-Paczynski distortion that comes from analysing the survey in a reference cosmology:
The Fisher matrix sums over the bins, each of volume \(V\) and galaxy density \(n\),
and the diagonal of its inverse gives the error on each parameter after marginalising over the rest.
The model is minimal. It leaves out the non-linear damping, the redshift errors and the shot-noise nuisance parameters of the Euclid forecast it is based on.
import jax
import jax.numpy as jnp
import numpy as np
from discoeb import LCDM, solve_eb
The fiducial cosmology#
The forecast works in \(\Omega_m\), \(\Omega_b\) and \(H_0\). from_density_parameters converts them into the model’s physical densities in JAX, so the derivatives pass through it.
h = 0.67
FIDUCIAL = dict(
Omega_m=0.32,
Omega_b=0.05,
H_0=100.0 * h,
A_s=2.1064e-9,
n_s=0.96,
T_cmb=2.7255,
Y_He=0.248,
N_eff=3.046,
)
The survey#
The bins, biases, volumes and galaxy densities come from the Euclid forecast of arXiv:1910.09273.
# 15000 square degrees in four redshift bins.
REDSHIFTS = np.array([1.0, 1.2, 1.4, 1.65])
BIASES = np.array([1.46, 1.61, 1.75, 1.90])
VOLUMES = np.array([7.94, 9.15, 10.05, 16.22]) * 1.0e9 / h**3 # Mpc^3
GALAXIES = np.array([1815.0, 1701.5, 1410.0, 940.97]) * 15000.0 # per unit redshift
DENSITIES = GALAXIES * np.array([0.2, 0.2, 0.2, 0.3]) / VOLUMES # 1/Mpc^3
K = np.geomspace(2.0e-4, 0.5, 128) # wave numbers of the solve, 1/Mpc
K_REF = np.geomspace(1.0e-3 * h, 0.25 * h, 96) # wave numbers the survey uses
MU = np.linspace(0.0, 1.0, 33)
The parameters#
The forecast varies four cosmological parameters, \(\ln 10^{10} A_s\) and one bias per bin. The logarithm keeps the Fisher matrix well scaled.
# Four cosmological parameters, ln(10^10 A_s) and one bias per bin.
COSMOLOGICAL = ("Omega_m", "Omega_b", "H_0", "n_s")
NAMES = (*COSMOLOGICAL, "ln10^10A_s", *(f"b(z={z})" for z in REDSHIFTS))
theta = jnp.asarray(
[
*(FIDUCIAL[key] for key in COSMOLOGICAL),
np.log(1.0e10 * FIDUCIAL["A_s"]),
*BIASES,
]
)
Save points#
solve_eb integrates in the scale factor and differentiates at fixed scale factor. It saves at the four bins’ redshifts and today, so every derivative below is at fixed redshift.
# The bins' scale factors, ascending as the solve saves them, then today.
A_BINS = 1.0 / (1.0 + REDSHIFTS)
A_SAVE = np.concatenate((A_BINS[::-1], [1.0]))
Linear theory in every bin#
One solve_eb gives \(P(k)\), the growth rate \(f = -(h'/2 + f_b \theta_b) / (a H \delta)\) and \(a H\) at each bin’s redshift. The conformal time tau is a state of the solve. The comoving distance to a bin is its value today minus its value at the bin.
def linear_theory(cosmology):
"""``P(k)`` and the growth rate ``f(k)``, each ``(bin, k)``, the distance and ``a H``, each ``(bin,)``."""
values = solve_eb(
cosmology,
K,
A_SAVE,
keep=("delta_c", "delta_b", "h_prime", "theta_b", "aH", "tau"),
)
tau0 = values[0, -1, 0, -1] # the conformal time today
# the bins, in the order of REDSHIFTS: each (k, bin)
delta_c, delta_b, h_prime, theta_b, aH, tau = values[0, :, :, -2::-1]
k = K[:, None]
f_b = cosmology.omega_b / (cosmology.omega_c + cosmology.omega_b)
delta = (1.0 - f_b) * delta_c + f_b * delta_b
growth_rate = -(0.5 * h_prime + f_b * theta_b) / (aH * delta)
primordial = cosmology.A_s * (k / cosmology.k_p) ** (cosmology.n_s - 1.0)
pk = 2.0 * jnp.pi**2 / k**3 * primordial * delta**2
return pk.T, growth_rate.T, tau0 - tau[0], aH[0]
The survey assumes the fiducial cosmology’s distances and expansion rates:
_, _, distance_ref, aH_ref = linear_theory(LCDM.from_density_parameters(**FIDUCIAL))
The observed spectrum#
observed_power returns one bin’s spectrum on the survey’s \((k_\mathrm{ref}, \mu_\mathrm{ref})\) grid, evaluated at the true wave number and angle each reference pair maps to.
def observed_power(pk, growth_rate, q_perp, q_par, bias):
"""One bin's ``P_obs(k_ref, mu_ref)`` in Mpc^3, ``(len(K_REF), len(MU))``."""
stretch = jnp.sqrt(1.0 + MU**2 * ((q_perp / q_par) ** 2 - 1.0))
k = K_REF[:, None] / q_perp * stretch # the true wave number and angle
mu = MU * q_perp / q_par / stretch
pk = jnp.exp(jnp.interp(jnp.log(k), np.log(K), jnp.log(pk)))
growth_rate = jnp.interp(jnp.log(k), np.log(K), growth_rate)
return (bias + growth_rate * mu**2) ** 2 * pk / (q_perp**2 * q_par)
log_power maps the parameters to \(\ln P_\mathrm{obs}\) in every bin, using jax.vmap over the bins.
def log_power(theta):
"""``ln P_obs`` of every bin, ``(bin, len(K_REF), len(MU))``."""
cosmology = LCDM.from_density_parameters(
**{
**FIDUCIAL,
**dict(zip(COSMOLOGICAL, theta)),
"A_s": 1.0e-10 * jnp.exp(theta[4]),
}
)
pk, growth_rate, distance, aH = linear_theory(cosmology)
power = jax.vmap(observed_power)(
pk, growth_rate, distance / distance_ref, aH_ref / aH, theta[-len(BIASES) :]
)
return jnp.log(power)
The derivatives#
One jax.jacfwd call gives the derivatives with respect to all nine parameters.
power = jnp.exp(log_power(theta))
derivatives = jax.jacfwd(log_power)(theta) # (bin, k, mu, parameter)
The Fisher matrix#
Trapezoid rules do the integrals over \(\mu\) and \(\ln k\), with \(k^2 \mathrm{d}k = k^3 \mathrm{d} \ln k\).
signal = DENSITIES[:, None, None] * power
weight = (signal / (1.0 + signal)) ** 2 * K_REF[:, None] ** 3 # k^2 dk = k^3 dln k
integrand = jnp.einsum("bkm,bkmi,bkmj->bkmij", weight, derivatives, derivatives)
over_mu = jnp.trapezoid(integrand, MU, axis=2)
per_bin = jnp.trapezoid(over_mu, np.log(K_REF), axis=1) # (bin, parameter, parameter)
fisher = jnp.einsum("b,bij->ij", VOLUMES / (4.0 * jnp.pi**2), per_bin)
The constraints#
The table lists the marginalised errors and, for comparison, the errors with every other parameter held fixed.
marginalised = np.sqrt(np.diag(np.linalg.inv(fisher)))
conditional = 1.0 / np.sqrt(np.diag(fisher))
print(
f"{'parameter':>10} {'fiducial':>10} {'1 sigma':>10} {'relative':>9} {'others fixed':>12}"
)
for name, value, sigma, fixed in zip(NAMES, theta, marginalised, conditional):
print(
f"{name:>10} {value:10.4g} {sigma:10.2e} {sigma / value:9.2%} {fixed:12.2e}"
)
parameter fiducial 1 sigma relative others fixed
Omega_m 0.32 4.05e-03 1.27% 1.61e-04
Omega_b 0.05 8.71e-04 1.74% 6.53e-05
H_0 67 5.49e-01 0.82% 2.35e-02
n_s 0.96 6.68e-03 0.70% 9.47e-04
ln10^10A_s 3.048 1.36e-02 0.45% 7.95e-04
b(z=1.0) 1.46 6.61e-03 0.45% 1.34e-03
b(z=1.2) 1.61 7.20e-03 0.45% 1.47e-03
b(z=1.4) 1.75 7.79e-03 0.45% 1.70e-03
b(z=1.65) 1.9 8.44e-03 0.44% 1.84e-03