gwkokab.analysis.subpopulation.common¶

Shared definitions for the subpopulation analysis family.

SubPopulationModelCore is the family half of the analysis matrix: it names the event coordinates the data must supply (parameters) and the flat list of population hyper-parameters to be inferred (model_parameters). Both are derived from the use_* flags, so switching a physical parameter on at the command line extends the parameter list automatically.

The model is SubPopulationModel(), built from N_spl power-law, N_bpl broken power-law and N_gpl truncated normal mass sub-populations. Hyper-parameter names carry the component tags spl, bpl and gpl, giving forms like alpha_pl_0.

This module is mixed with a data-representation base and a sampler mixin to form a complete analysis; see the discrete and analytical_gwalk modules alongside it.

Classes¶

SubPopulationModelCore

Family half of the subpopulation analysis.

Functions¶

model_arg_parser(→ argparse.ArgumentParser)

Populate the command line argument parser with this family's model arguments.

where_fns_list(→ Optional[List[Callable[..., ...)

Build the extra validity predicates this configuration needs.

Module Contents¶

class gwkokab.analysis.subpopulation.common.SubPopulationModelCore(N_spl: int, N_bpl: int, N_gpl: int, use_beta_spin_magnitude: bool, use_spin_magnitude_mixture: bool, use_truncated_normal_spin_x: bool, use_truncated_normal_spin_y: bool, use_truncated_normal_spin_z: bool, use_chi_eff_mixture: bool, use_skew_normal_chi_eff: bool, use_truncated_normal_chi_p: bool, use_tilt: bool, use_eccentricity_mixture: bool, use_eccentricity_powerlaw: bool, use_mean_anomaly: bool, use_powerlaw_redshift: bool, use_madau_dickinson_redshift: bool)¶

Family half of the subpopulation analysis.

Mixed with a data-representation base – DiscreteBase or AnalyticalGWalkBase – and a sampler mixin, to form a complete analysis.

See __init__() for the constructor arguments.

Record which components and physical parameters this analysis uses.

The use_* flags decide both what the model contains and, through parameters and model_parameters, what the data must supply and what will be inferred.

Parameters:
  • N_spl (int) – Number of power-law sub-populations.

  • N_bpl (int) – Number of broken power-law sub-populations.

  • N_gpl (int) – Number of truncated normal sub-populations.

  • use_beta_spin_magnitude (bool) – Model both spin magnitudes with beta distributions.

  • use_spin_magnitude_mixture (bool) – Model both spin magnitudes jointly with a two-truncated-normal mixture.

  • use_truncated_normal_spin_x (bool) – Model both Cartesian x spin components with truncated normals.

  • use_truncated_normal_spin_y (bool) – Model both Cartesian y spin components with truncated normals.

  • use_truncated_normal_spin_z (bool) – Model both aligned spin components with truncated normals.

  • use_chi_eff_mixture (bool) – Model the effective spin with a two-truncated-normal mixture.

  • use_skew_normal_chi_eff (bool) – Model the effective spin with the GWTC-4 skew normal.

  • use_truncated_normal_chi_p (bool) – Model the precessing spin with a truncated normal.

  • use_tilt (bool) – Model both tilt cosines jointly with the generic tilt model.

  • use_eccentricity_mixture (bool) – Model eccentricity with a two-truncated-normal mixture.

  • use_eccentricity_powerlaw (bool) – Model eccentricity with a truncated power law.

  • use_mean_anomaly (bool) – Model the mean anomaly with a uniform distribution.

  • use_powerlaw_redshift (bool) – Model redshift with a power law rate evolution.

  • use_madau_dickinson_redshift (bool) – Model redshift with the Madau-Dickinson rate evolution.

modify_model_params(params: dict) → dict¶

Inject the component counts and use_* flags into the model parameters.

The prior configuration supplies only the hyper-parameters to be inferred; the model factory also needs to know how many components of each kind to build and which physical parameters were switched on. This hook adds them.

Parameters:

params (dict) – The processed priors, keyed by hyper-parameter name.

Returns:

params, with the counts and flags added.

Return type:

dict

N_bpl¶
N_gpl¶
N_spl¶
model_fn¶

The population model factory, SubPopulationModel().

property model_parameters: list[str]¶

The flat list of population hyper-parameters to be inferred.

Each entry is a per-component name of the form <role>_<component tag>_<index>, expanded from the enabled use_* flags by expand_arguments(). These names are what the regex keys of prior_cfg.json are matched against.

Returns:

Hyper-parameter names.

Return type:

list[str]

property parameters: tuple[str, ...]¶

The event coordinates this analysis reads from the data.

Always the two component masses, plus whichever spin, tilt, eccentricity, redshift and extrinsic coordinates the use_* flags switched on.

Returns:

Parameter names, in the order the model’s event axis expects them.

Return type:

tuple[str, …]

use_beta_spin_magnitude¶
use_chi_eff_mixture¶
use_eccentricity_mixture¶
use_eccentricity_powerlaw¶
use_madau_dickinson_redshift¶
use_mean_anomaly¶
use_powerlaw_redshift¶
use_skew_normal_chi_eff¶
use_spin_magnitude_mixture¶
use_tilt¶
use_truncated_normal_chi_p¶
use_truncated_normal_spin_x¶
use_truncated_normal_spin_y¶
use_truncated_normal_spin_z¶
gwkokab.analysis.subpopulation.common.model_arg_parser(parser: argparse.ArgumentParser) → argparse.ArgumentParser¶

Populate the command line argument parser with this family’s model arguments.

Adds the component counts and one --add-* flag per optional physical parameter.

Parameters:

parser (ArgumentParser) – Parser to add the arguments to.

Returns:

The same parser, with the arguments added.

Return type:

ArgumentParser

gwkokab.analysis.subpopulation.common.where_fns_list(use_beta_spin_magnitude: bool) → List[Callable[..., jaxtyping.Array]] | None¶

Build the extra validity predicates this configuration needs.

These are applied on top of the prior support: a point failing any of them is assigned \(-\infty\) without the model ever being built.

Parameters:

use_beta_spin_magnitude (bool) – Whether spin magnitudes are modelled with beta distributions, which need their mean/variance pairs checked for validity.

Returns:

The predicates, or None when none are needed.

Return type:

Optional[List[Callable[…, Array]]]