Population-level Bayesian inference to test whether gravitational wave observations are consistent with General Relativity.
This method asks: what fraction of detected events are consistent with GR?
Using a mixture model framework, we infer ζ ∈ [0,1], where:
- ζ = 1: all events consistent with GR
- ζ < 1: some fraction exhibits deviations
The method as such is more generic, and the "base" code is written accordingly.
git clone https://github.com/yourusername/mixture-models-tgr.git
cd mixture-models-tgr
pip install -r requirements.txtimport pylab
from mixture_model import MixtureModelPopulation
# Your per-event log Bayes factors (log10 scale)
log_bayes_factors = [0.3, 0.5, -0.2, 0.1, ...] # GR vs beyond-GR
# Fit mixture model
mixture = MixtureModelPopulation(log_bayes_factors, prior='uniform')
# Get results
lower, upper, median = mixture.credible_interval(level=0.9)
print(f"GR fraction: ζ = {median:.2f} [90% CI: {lower:.2f}, {upper:.2f}]")
# Plot
zeta_grid, posterior = mixture.posterior()
pylab.plot(zeta_grid, posterior)
pylab.xlabel('ζ (GR fraction)')
pylab.ylabel('p(ζ | data)')If you use this for an analysis, we would appreciate it if you acknowledge our work: