Bayesian Inference¶
Pipeline A — self-contained MWE for Hubble constant inference (dev cross-check).
This module provides BayesianInference, a minimal working example that
estimates the Hubble constant posterior from synthetic EMRI detections and a
GalaxyCatalog. It uses:
An erf-based analytic GW detection probability,
A hardcoded 10 % fractional σ(d_L) (see
FRACTIONAL_LUMINOSITY_ERROR),A synthetic galaxy catalog generated by
GalaxyCatalog.
This pipeline is NOT invoked by ``–evaluate``. It exists for rapid
prototyping and cross-checking. The production (science-grade) pipeline is
BayesianStatistics
(Pipeline B), which uses the real GLADE galaxy catalog, KDE-based detection
probability, full Fisher-matrix covariance, and multiprocessing.
The __main__ entry point in
bayesian_inference_mwe runs
this pipeline standalone.
- class master_thesis_code.bayesian_inference.bayesian_inference.BayesianInference(galaxy_catalog, emri_detections, luminosity_distance_threshold=1.55, number_of_redshift_steps=1000, redshift_values=<factory>, galaxy_distribution_at_redshifts=<factory>, galaxy_detection_mass_distribution_at_redshifts=<factory>, detection_skylocalization_weight_by_galaxy=<factory>, use_bh_mass=False, use_selection_effects_correction=True)[source]¶
Bases:
objectBayesian estimator for the Hubble constant H₀ from EMRI detections.
Evaluates \(p(H_0 \mid \{d_i\})\) by marginalizing each detection over the galaxy-catalog redshift distribution, weighted by the GW likelihood and sky-localization overlap.
- Variables:
galaxy_catalog (master_thesis_code.datamodels.galaxy.GalaxyCatalog) – Galaxy catalog providing redshift and mass distributions \(p(z)\) and \(p(M)\).
emri_detections (list[master_thesis_code.datamodels.emri_detection.EMRIDetection]) – List of EMRI detections with measured luminosity distances and sky positions.
luminosity_distance_threshold (float) – LISA detection horizon in Gpc.
number_of_redshift_steps (int) – Number of quadrature points for redshift integrals.
redshift_values (numpy.ndarray[tuple[Any, ...], numpy.dtype[numpy.float64]]) – Redshift grid used for all integrals, set in
__post_init__.galaxy_distribution_at_redshifts (numpy.ndarray[tuple[Any, ...], numpy.dtype[numpy.float64]]) – Pre-computed \(p(z_i \mid \mathrm{catalog})\) evaluated on
redshift_values.use_bh_mass (bool) – If
True, include BH mass information in the likelihood.use_selection_effects_correction (bool) – If
True, divide likelihood by the selection-function denominator \(\int p_\mathrm{det}(z) p(z) dz\).
- Parameters:
galaxy_catalog (GalaxyCatalog)
emri_detections (list[EMRIDetection])
luminosity_distance_threshold (float)
number_of_redshift_steps (int)
galaxy_distribution_at_redshifts (ndarray[tuple[Any, ...], dtype[float64]])
galaxy_detection_mass_distribution_at_redshifts (list)
detection_skylocalization_weight_by_galaxy (list)
use_bh_mass (bool)
use_selection_effects_correction (bool)
- emri_detections: list[EMRIDetection]¶
- galaxy_catalog: GalaxyCatalog¶
- gw_detection_probability(redshift, hubble_constant)[source]¶
Probability that a source at redshift is detected by LISA.
Models the detector selection function as a cumulative normal:
\[p_\mathrm{det}(z) = \frac{1}{2}\left[1 + \mathrm{erf}\! \left(\frac{D_\mathrm{thr} - d_L(z)}{\sqrt{2}\,\sigma_{d_L}(z)}\right)\right]\]where \(\sigma_{d_L} = f_\sigma \cdot d_L(z)\) and \(f_\sigma\) is
FRACTIONAL_LUMINOSITY_ERROR.
- gw_likelihood(measured_luminosity_distance, redshift, hubble_constant)[source]¶
GW likelihood: probability of measuring measured_luminosity_distance given redshift.
Assumes Gaussian measurement noise:
\[\mathcal{L}(\hat{d}_L \mid z, h) = \mathcal{N}\!\left(\hat{d}_L;\, d_L(z, h),\, f_\sigma \cdot d_L(z, h)\right)\]
- likelihood(hubble_constant, measured_luminosity_distance, measured_redshifted_mass, detection_index)[source]¶
Marginalized likelihood \(p(\hat{d}_L \mid H_0)\) for one EMRI detection.
Integrates the GW likelihood over the galaxy-catalog redshift distribution, weighted by sky-localization overlap and — optionally — BH mass information. A selection-effects correction divides by the denominator integral when
use_selection_effects_correctionisTrue:\[\mathcal{L}(H_0) = \frac{\int p_\mathrm{GW}(\hat{d}_L \mid z, H_0)\, p_\mathrm{det}(z, H_0)\, p(z \mid \mathrm{catalog})\, dz} {\int p_\mathrm{det}(z, H_0)\, p(z \mid \mathrm{catalog})\, dz}\]- Parameters:
hubble_constant (float) – Dimensionless Hubble parameter \(h\) being evaluated.
measured_luminosity_distance (float) – Measured \(\hat{d}_L\) in Gpc.
measured_redshifted_mass (float) – Measured redshifted BH mass \(M_z\) in solar masses.
detection_index (int) – Index into
emri_detectionsand pre-computed weight arrays.
- Returns:
Likelihood value (positive real number; not normalized over \(H_0\)).
- Return type:
- master_thesis_code.bayesian_inference.bayesian_inference.dist_array(redshifts, h=H, Omega_m=OMEGA_M, Omega_de=OMEGA_DE)[source]¶
Vectorized luminosity distance in Gpc over an array of redshifts.
Delegates to physical_relations.dist_vectorized for a canonical, unit-consistent implementation. Returns Gpc (same unit as the scalar dist()).