psiphy.toy_models
- class psiphy.toy_models.gaussian.GaussianSignal(N=20, mean_range=(-5, 5), sigma_range=(0.1, 5))[source]
Simple 1-D Gaussian signal model with known analytic likelihood.
- Parameters:
N (int) – Number of data points per simulation.
mean_range (tuple) – Prior range for the mean parameter.
sigma_range (tuple) – Prior range for the sigma parameter (must be > 0).
Notes
Parameters: theta = [mean, sigma]. Analytic log-likelihood available via
log_prob().- param_names = ['mean', 'sigma']
- psiphy.toy_models.gaussian.gaussian_signal
alias of
GaussianSignal
- class psiphy.toy_models.line_fitting.NoisyLine(Nx=50, x_range=(0, 10), noise_sigma=0.5, slope_range=(-3, 3), intercept_range=(0, 10))[source]
Noisy linear model: y = slope * x + intercept + noise.
- Parameters:
Nx (int) – Number of x points.
x_range (tuple) – Range of x values.
noise_sigma (float) – Fixed Gaussian noise std (used for log_prob).
slope_range (tuple) – Prior range for slope.
intercept_range (tuple) – Prior range for intercept.
Notes
Parameters: theta = [slope, intercept]. Analytic log-likelihood available via
log_prob()(assumes fixed noise_sigma).- param_names = ['slope', 'intercept']
- class psiphy.toy_models.ma2.MA2Model(n_obs=100)[source]
Moving Average(2) process — standard LFI benchmark.
Generative model: x_t = w_t + theta_1 * w_{t-1} + theta_2 * w_{t-2}, where w_t ~ N(0, 1) i.i.d.
- Parameters:
n_obs (int) – Length of the time series.
Notes
Parameters: theta = [theta_1, theta_2]. The prior is uniform on the MA(2) invertibility region: |theta_2| < 1, theta_2 + theta_1 > -1, theta_2 - theta_1 > -1.
The likelihood is intractable; log_prob returns None. Summary statistics returned by simulate: [mean, variance, lag-1 autocov, lag-2 autocov].
- param_names = ['theta_1', 'theta_2']
- class psiphy.toy_models.cosmological.PowerLawSpectrum(ells=None, noise_sigma=0.05, ell_pivot=100.0, A_s_range=(0.5, 2.0), n_s_range=(0.85, 1.15))[source]
Simple power-law angular power spectrum toy model.
Simulates noisy band-power measurements of a CMB-like spectrum:
C_ell = A_s * (ell / ell_pivot) ** (n_s - 1)
with independent Gaussian noise on each band power.
- Parameters:
ells (array-like or None) – Multipole values at which the spectrum is evaluated. Defaults to 20 log-spaced values from 10 to 2000.
noise_sigma (float) – Noise std per band power (in same units as C_ell).
ell_pivot (float) – Pivot multipole for the tilt (default 100).
A_s_range (tuple) – Prior range for the amplitude A_s.
n_s_range (tuple) – Prior range for the spectral index n_s.
Notes
Parameters: theta = [A_s, n_s]. Analytic Gaussian log-likelihood available via
log_prob().- param_names = ['A_s', 'n_s']
- class psiphy.toy_models.lotka_volterra.LotkaVolterra(t_obs=None, x0=10.0, y0=5.0, noise_sigma=0.5, alpha_range=(0.5, 2.0), beta_range=(0.02, 0.2), delta_range=(0.02, 0.2), gamma_range=(0.5, 2.0))[source]
Lotka-Volterra predator-prey model.
Stochastic observations of the ODE system:
dx/dt = alpha * x - beta * x * y (prey) dy/dt = delta * x * y - gamma * y (predator)
with independent Gaussian noise added to each species at each observation time, making the likelihood tractable.
- Parameters:
t_obs (array-like or None) – Observation times. Defaults to 20 equally-spaced points on [0, 15].
x0 (float) – Initial prey population.
y0 (float) – Initial predator population.
noise_sigma (float) – Gaussian noise std added to each observation.
alpha_range (tuple) – Prior range for prey growth rate alpha.
beta_range (tuple) – Prior range for predation rate beta.
delta_range (tuple) – Prior range for predator growth rate delta.
gamma_range (tuple) – Prior range for predator death rate gamma.
Notes
Parameters:
theta = [alpha, beta, delta, gamma].Typical values: alpha ~ 1.0, beta ~ 0.1, delta ~ 0.075, gamma ~ 1.5.
simulate()returns a 1-D array of length2 * len(t_obs): prey observations followed by predator observations.log_prob()returns the analytic Gaussian log-likelihood.- param_names = ['alpha', 'beta', 'delta', 'gamma']