ler.gw_source_population.cbc_source_parameter_distribution

Module for sampling compact binary coalescence (CBC) source parameters.

This module provides the CBCSourceParameterDistribution class for generating complete sets of intrinsic and extrinsic gravitational wave parameters for compact binary sources (BBH, BNS, NSBH). It includes mass distributions, spin parameters, sky positions, and other parameters needed for GW analysis.

Inheritance hierarchy:

  • CBCSourceRedshiftDistribution

Usage:

Basic workflow example:

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc = CBCSourceParameterDistribution(event_type='BBH')
>>> params = cbc.gw_parameters_rvs(size=1000)
>>> print(list(params.keys()))

Module Contents

Classes

CBCSourceParameterDistribution

Class for sampling compact binary coalescence source parameters.

Attributes

chunk_size

ler.gw_source_population.cbc_source_parameter_distribution.chunk_size = '10000'[source]
class ler.gw_source_population.cbc_source_parameter_distribution.CBCSourceParameterDistribution(npool=4, z_min=0.0, z_max=10.0, event_type='BBH', gw_functions=None, gw_functions_params=None, gw_priors=None, gw_priors_params=None, cosmology=None, spin_zero=False, spin_precession=False, directory='./interpolator_json', create_new_interpolator=False, verbose=False)[source]

Bases: ler.gw_source_population.cbc_source_redshift_distribution.CBCSourceRedshiftDistribution

Class for sampling compact binary coalescence source parameters.

This class generates complete sets of intrinsic and extrinsic gravitational wave parameters for compact binary sources including masses, spins, sky positions, and orbital parameters. It supports BBH, BNS, NSBH, and primordial black hole populations with configurable prior distributions.

Key Features:

  • Multiple mass distribution models (PowerLaw+Gaussian, lognormal, bimodal)

  • Configurable spin priors (zero, aligned, precessing)

  • Isotropic sky position and orientation sampling

  • Built-in support for population III and primordial black holes

Parameters:
npoolint

Number of processors to use for multiprocessing and numba threads.

default: 4

z_minfloat

Minimum redshift of the source population.

default: 0.0

z_maxfloat

Maximum redshift of the source population.

default: 10.0

event_typestr

Type of compact binary event to generate.

Options:

  • ‘BBH’: Binary black hole (Population I/II)

  • ‘BNS’: Binary neutron star

  • ‘NSBH’: Neutron star-black hole

  • ‘BBH_popIII’: Population III binary black hole

  • ‘BBH_primordial’: Primordial binary black hole

default: ‘BBH’

gw_priorsdict or None

Dictionary of prior sampler functions for each parameter.

If None, uses default priors based on event_type.

default: None

gw_priors_paramsdict or None

Dictionary of parameters for each prior sampler function.

If None, uses default parameters based on event_type.

default: None

cosmologyastropy.cosmology or None

Cosmology to use for distance calculations.

default: LambdaCDM(H0=70, Om0=0.3, Ode0=0.7, Tcmb0=0.0, Neff=3.04, m_nu=None, Ob0=0.0)

spin_zerobool

If True, spin parameters are set to zero (no spin sampling).

default: False

spin_precessionbool

If True (and spin_zero=False), sample precessing spin parameters.

If False (and spin_zero=False), sample aligned/anti-aligned spins.

default: False

directorystr

Directory to store interpolator JSON files.

default: ‘./interpolator_json’

create_new_interpolatordict or bool

Configuration for creating new interpolators.

If bool, applies to all interpolators.

default: False

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc = CBCSourceParameterDistribution(event_type='BBH')
>>> params = cbc.gw_parameters_rvs(size=1000)
>>> print(list(params.keys()))
property zs[source]

Class object (of FunctionConditioning) for source redshift, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the redshift distribution

  • pdf: returns the probability density function of the redshift distribution

  • function: returns the redshift distribution function.

Returns:
zsnumpy.ndarray

Array of redshift values.

property mass_1_source[source]

Class object (of FunctionConditioning) for source frame primary mass, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • function(m1): returns the primary mass distribution function in terms of the merger rate at fixed redshift.

  • pdf(m1): returns the probability density function of the primary mass distribution.

  • rvs(size): returns random samples from the primary mass distribution.

Returns:
mass_1_sourcenumpy.ndarray

Array of mass_1_source values in solar masses.

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc_source_param_dist = CBCSourceParameterDistribution()
>>> cbc_source_param_dist.mass_1_source(size=10)
property geocent_time[source]

Class object (of FunctionConditioning) for geocentric time, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the geocentric time distribution

  • pdf: returns the probability density function of the geocentric time distribution

  • function: returns the geocentric time distribution function.

Returns:
geocent_timenumpy.ndarray

Array of geocentric time values.

property ra[source]

Class object (of FunctionConditioning) for right ascension, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the right ascension distribution

  • pdf: returns the probability density function of the right ascension distribution

  • function: returns the right ascension distribution function.

Returns:
ranumpy.ndarray

Array of right ascension values.

property dec[source]

Class object (of FunctionConditioning) for declination, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the declination distribution

  • pdf: returns the probability density function of the declination distribution

  • function: returns the declination distribution function.

Returns:
decnumpy.ndarray

Array of declination values.

property phase[source]

Class object (of FunctionConditioning) for coalescence phase, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the coalescence phase distribution

  • pdf: returns the probability density function of the coalescence phase distribution

  • function: returns the coalescence phase distribution function.

Returns:
phasenumpy.ndarray

Array of coalescence phase values.

property psi[source]

Class object (of FunctionConditioning) for polarization angle, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the polarization angle distribution

  • pdf: returns the probability density function of the polarization angle distribution

  • function: returns the polarization angle distribution function.

Returns:
psinumpy.ndarray

Array of polarization angle values.

property theta_jn[source]

Class object (of FunctionConditioning) for inclination angle, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the inclination angle distribution

  • pdf: returns the probability density function of the inclination angle distribution

  • function: returns the inclination angle distribution function.

Returns:
theta_jnnumpy.ndarray

Array of inclination angle values, i.e. the angle between the line of sight and the orbital angular momentum (rad).

property a_1[source]

Class object (of FunctionConditioning) for spin1 magnitude, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the spin1 magnitude distribution

  • pdf: returns the probability density function of the spin1 magnitude distribution

  • function: returns the spin1 magnitude distribution function.

  • None : if spin_zero=True.

Returns:
a_1numpy.ndarray

Array of spin magnitude values for the primary body.

property a_2[source]

Class object (of FunctionConditioning) for spin2 magnitude, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the spin2 magnitude distribution

  • pdf: returns the probability density function of the spin2 magnitude distribution

  • function: returns the spin2 magnitude distribution function.

  • None : if spin_zero=True.

Returns:
a_2numpy.ndarray

Array of spin magnitude values for the secondary body.

property tilt_1[source]

Class object (of FunctionConditioning) for tilt1 angle, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the tilt1 angle distribution

  • pdf: returns the probability density function of the tilt1 angle distribution

  • function: returns the tilt1 angle distribution function.

  • None : if spin_zero=True or spin_precession=False.

Returns:
tilt_1numpy.ndarray

Array of the spin tilt angle of the primary body, i.e. the angle between the spin vector and the orbital angular momentum for the primary body (rad).

property tilt_2[source]

Class object (of FunctionConditioning) for tilt2 angle, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the tilt2 angle distribution

  • pdf: returns the probability density function of the tilt2 angle distribution

  • function: returns the tilt2 angle distribution function.

  • None : if spin_zero=True or spin_precession=False.

Returns:
tilt_2numpy.ndarray

Array of the spin tilt angle of the secondary body, i.e. the angle between the spin vector and the orbital angular momentum for the secondary body (rad).

property phi_12[source]

Class object (of FunctionConditioning) for phi_12 angle, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the phi_12 angle distribution

  • pdf: returns the probability density function of the phi_12 angle distribution

  • function: returns the phi_12 angle distribution function.

  • None : if spin_zero=True or spin_precession=False.

Returns:
phi_12numpy.ndarray

Array of the spin tilt angle between the two spins, i.e., angle between the projections of the two spins onto the orbital plane (rad).

property phi_jl[source]

Class object (of FunctionConditioning) for phi_jl angle, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs: returns random samples from the phi_jl angle distribution

  • pdf: returns the probability density function of the phi_jl angle distribution

  • function: returns the phi_jl angle distribution function.

  • None : if spin_zero=True or spin_precession=False.

Returns:
phi_jlnumpy.ndarray

Array of the angle values between the orientation of the total angular momentum around the orbital angular momentum (rad).

property mass_ratio[source]

Class object (of FunctionConditioning) for mass ratio, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • rvs(size) or rvs(size, m1): returns random samples from the mass ratio distribution

  • pdf(q) or pdf(q, m1): returns the probability density function of the mass ratio distribution

Returns:
mass_rationumpy.ndarray

Array of mass ratio values.

property mass_2_source[source]

Class object (of FunctionConditioning) for source frame secondary mass, with rvs/sampler as callback. Can also be a user defined callable sampler.

The class object contains the following attribute methods:

  • function(m1): returns the secondary mass distribution function in terms of the merger rate at fixed redshift.

  • pdf(m1): returns the probability density function of the secondary mass distribution.

  • rvs(size): returns random samples from the secondary mass distribution.

Returns:
mass_2_sourcenumpy.ndarray

Array of mass_2_source values in solar masses.

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc_source_param_dist = CBCSourceParameterDistribution()
>>> cbc_source_param_dist.mass_2_source(size=10)
property available_gw_prior[source]

Dictionary of all available prior distributions and their parameters.

This is a dynamically generated dictionary containing available samplers for each GW parameter type and their default parameter values.

Returns:
available_gw_priordict

Nested dictionary organized by parameter type (e.g., ‘mass_1_source’,

‘geocent_time’, etc.) with sampler names and default parameters.

property available_gw_functions[source]

Dictionary of available gravitational wave related functions and their default parameters.

Returns:
available_gw_functionsdict

Dictionary with function names and default parameters.

z_min = 'None'[source]

float

Minimum redshift of the source population

z_max = 'None'[source]

float

Maximum redshift of the source population

event_type = 'None'[source]

str

Type of event to generate.

e.g. ‘BBH’, ‘BNS’, ‘NSBH’

gw_priors = 'None'[source]

dict

Dictionary of prior sampler functions.

gw_priors_params = 'None'[source]

dict

Dictionary of prior sampler functions’ input parameters.

cosmo[source]

astropy.cosmology

Cosmology to use.

spin_zero = 'None'[source]

bool

If True, spin prior is set to zero.

spin_precession = 'False'[source]
directory = "'./interpolator_json'"[source]

Directory path for storing interpolator JSON files.

Returns:
directorystr

Path to the interpolator storage directory.

default: ‘./interpolator_json’

gw_parameters_rvs_routine[source]
sample_gw_parameters_routine[source]
sample_gw_parameters(size=1000, param=None)[source]

Sample all gravitational wave parameters for compact binaries.

This method samples GW parameters using the specified routine and returns a dictionary with redshift, masses, luminosity distance, and orientation parameters.

Parameters:
sizeint

Number of samples to draw. default: 1000

paramdict or None

Dictionary of fixed parameter values.

Parameters in this dict will not be sampled.

default: None

Returns:
gw_parametersdict

Dictionary of sampled GW parameters. The included parameters and their units are as follows (for default settings):

Parameter

Units

Description

zs

redshift of the source

geocent_time

s

GPS time of coalescence

ra

rad

right ascension

dec

rad

declination

phase

rad

phase of GW at reference frequency

psi

rad

polarization angle

theta_jn

rad

inclination angle

a_1

spin_1 of the compact binary

a_2

spin of the secondary compact binary

luminosity_distance

Mpc

luminosity distance

mass_1_source

Msun

mass_1 of the compact binary (source frame)

mass_2_source

Msun

mass_2 of the compact binary (source frame)

mass_1

Msun

mass_1 of the compact binary (detector frame)

mass_2

Msun

mass_2 of the compact binary (detector frame)

gw_parameters_rvs(size=1000, **kwargs)[source]

Sample all gravitational wave parameters for compact binaries.

This method samples GW parameters using the specified routine and returns a dictionary with redshift, masses, luminosity distance, and orientation parameters.

Parameters:
sizeint

Number of samples to draw. default: 1000

**kwargsdict

Dictionary of fixed parameter values.

Parameters in this dict will not be sampled.

e.g. mass_1_source, mass_2_source, mass_ratio, zs, geocent_time, ra, dec, phase, psi, theta_jn, a_1, a_2, tilt_1, tilt_2, phi_12, phi_jl

Returns:
gw_parametersdict

Dictionary of sampled GW parameters. The included parameters and their units are as follows (for default settings):

Parameter

Units

Description

zs

redshift of the source

geocent_time

s

GPS time of coalescence

ra

rad

right ascension

dec

rad

declination

phase

rad

phase of GW at reference frequency

psi

rad

polarization angle

theta_jn

rad

inclination angle

a_1

spin_1 of the compact binary

a_2

spin of the secondary compact binary

luminosity_distance

Mpc

luminosity distance

mass_1_source

Msun

mass_1 of the compact binary (source frame)

mass_2_source

Msun

mass_2 of the compact binary (source frame)

mass_1

Msun

mass_1 of the compact binary (detector frame)

mass_2

Msun

mass_2 of the compact binary (detector frame)

gw_parameters_rvs_njit(size=1000, **kwargs)[source]

Sample all gravitational wave parameters for compact binaries.

This method samples GW parameters using the specified routine and returns a dictionary with redshift, masses, luminosity distance, and orientation parameters.

Parameters:
sizeint

Number of samples to draw. default: 1000

Returns:
gw_parametersdict

Dictionary of sampled GW parameters. The included parameters and their units are as follows (for default settings):

Parameter

Units

Description

zs

redshift of the source

geocent_time

s

GPS time of coalescence

ra

rad

right ascension

dec

rad

declination

phase

rad

phase of GW at reference frequency

psi

rad

polarization angle

theta_jn

rad

inclination angle

a_1

spin_1 of the compact binary

a_2

spin of the secondary compact binary

luminosity_distance

Mpc

luminosity distance

mass_1_source

Msun

mass_1 of the compact binary (source frame)

mass_2_source

Msun

mass_2 of the compact binary (source frame)

mass_1

Msun

mass_1 of the compact binary (detector frame)

mass_2

Msun

mass_2 of the compact binary (detector frame)

broken_powerlaw_plus_2peaks(size, get_attribute=False, **kwargs)[source]

Sample primary source mass with broken power-law + two peaks model for BBH.

Implements the mass distribution model combining a broken power-law with two Gaussian peaks for modeling specific mass populations.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • lam_0: Fraction of broken power-law component, default: 0.361

  • lam_1: Fraction of first Gaussian peak, default: 0.586

  • mpp_1: Mean of first Gaussian peak (Msun), default: 9.764

  • sigpp_1: Std dev of first Gaussian peak (Msun), default: 0.649

  • mpp_2: Mean of second Gaussian peak (Msun), default: 32.763

  • sigpp_2: Std dev of second Gaussian peak (Msun), default: 3.918

  • mlow_1: Minimum primary mass (Msun), default: 5.059

  • delta_m_1: Low-mass tapering range (Msun), default: 4.321

  • break_mass: Power-law break mass (Msun), default: 35.622

  • alpha_1: Power-law index below break, default: 1.728

  • alpha_2: Power-law index above break, default: 4.512

  • mmax: Maximum primary mass (Msun), default: 300.0

  • beta: Mass ratio power-law index, default: 1.171

  • mlow_2: Minimum secondary mass (Msun), default: 3.551

  • delta_m_2: Secondary mass tapering range (Msun), default: 4.910

Returns:
mass_1_sourcenumpy.ndarray

Array of primary masses in source frame (Msun).

mass_2_sourcenumpy.ndarray

Array of secondary masses in source frame (Msun).

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc = CBCSourceParameterDistribution()
>>> m1_src, m2_src = cbc.broken_powerlaw_plus_2peaks(size=1000)
powerlaw_plus_peak(size, get_attribute=False, **kwargs)[source]

Sample source masses with PowerLaw+PEAK model for Population I/II BBH.

GWTC-3 parameters: mminbh=4.98, mmaxbh=112.5, alpha=3.78, mu_g=32.27, sigma_g=3.88, lambda_peak=0.03, delta_m=4.8, beta=0.81

Implements the mass distribution model from LIGO-Virgo population analyses combining a power-law with a Gaussian peak component. Uses separate m1 and q interpolators with joint composite sampling.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • mminbh: Minimum BH mass (Msun), default: 4.98

  • mmaxbh: Maximum BH mass (Msun), default: 112.5

  • alpha: Power-law spectral index, default: 3.78

  • mu_g: Gaussian peak mean (Msun), default: 32.27

  • sigma_g: Gaussian peak width (Msun), default: 3.88

  • lambda_peak: Fraction in Gaussian component, default: 0.03

  • delta_m: Low-mass tapering range (Msun), default: 4.8

  • beta: Mass ratio power-law index, default: 0.81

Returns:
mass_1_sourcenumpy.ndarray

Array of primary masses in source frame (Msun).

mass_2_sourcenumpy.ndarray

Array of secondary masses in source frame (Msun).

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc = CBCSourceParameterDistribution()
>>> m1_src, m2_src = cbc.powerlaw_plus_peak(size=1000)
powerlaw_with_smoothing(size, get_attribute=False, **kwargs)[source]

Sample mass ratio with power-law distribution with smoothing near q=1.

Implements a power-law distribution for the mass ratio with an additional smoothing function to account for the observed excess of equal-mass binaries.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • q_min: Minimum mass ratio, default: 0.01

  • q_max: Maximum mass ratio, default: 1.0

  • beta: Power-law index, default: 1.171

  • mlow_2: Minimum secondary mass (Msun), default: 3.551

  • delta_m_2: Tapering range for secondary mass (Msun), default: 4.910

Returns:
qnumpy.ndarray

Array of mass ratios (m2/m1) for the binary systems.

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc = CBCSourceParameterDistribution()
>>> m1 = cbc.broken_powerlaw_plus_2peaks(1000)
>>> q_samples = cbc.powerlaw_with_smoothing(1000, m1)
gaussian_plus_isotropic(size, get_attribute=False, **kwargs)[source]

Sample from tilt_1 distribution for spin tilt angle of primary mass.

Samples values in range [-1, 1] and converts to tilt angles in radians. Combines a truncated Gaussian component with an isotropic distribution.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

Returns:
valuesnumpy.ndarray

Array of tilt_1 angles.

gaussian_plus_isotropic_joint(size, get_attribute=False, **kwargs)[source]

Sample from tilt_2 distribution for spin tilt angle of secondary mass, given the tilt_1 distribution for primary mass.

Samples values in range [-1, 1] and converts to tilt angles in radians. Combines a truncated Gaussian component with an isotropic distribution.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

Returns:
valuesnumpy.ndarray

Array of tilt_2 angles.

bimodal(size, get_attribute=False, **kwargs)[source]

Sample BNS primary mass from bimodal Gaussian distribution.

Based on Will M. Farr et al. 2020 Eq. 6 for neutron star mass distribution combining two Gaussian peaks.

\[p(m) = w\,\mathcal{N}(m \mid \mu_L, \sigma_L) + (1-w)\,\mathcal{N}(m \mid \mu_R, \sigma_R),\]

truncated to [mmin, mmax].

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • w: Weight of left peak, default: 0.643

  • muL: Mean of left peak (Msun), default: 1.352

  • sigmaL: Width of left peak (Msun), default: 0.08

  • muR: Mean of right peak (Msun), default: 1.88

  • sigmaR: Width of right peak (Msun), default: 0.3

  • mmin: Minimum mass (Msun), default: 1.0

  • mmax: Maximum mass (Msun), default: 2.3

Returns:
mass_1_sourcenumpy.ndarray

Array of primary masses in source frame (Msun).

Examples

>>> from ler.gw_source_population import CBCSourceParameterDistribution
>>> cbc = CBCSourceParameterDistribution(event_type='BNS')
>>> m1_src = cbc.bimodal(size=1000)
broken_powerlaw(size, get_attribute=False, **kwargs)[source]

Sample source masses for NSBH from broken power-law distribution.

Uses gwcosmo-style broken power-law for black hole mass and power-law for neutron star mass.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • mminbh: Minimum BH mass (Msun), default: 26

  • mmaxbh: Maximum BH mass (Msun), default: 125

  • alpha_1: Primary power-law index, default: 6.75

  • alpha_2: Secondary power-law index, default: 6.75

  • b: Break point, default: 0.5

  • delta_m: Tapering range (Msun), default: 5

Returns:
mass_1_sourcenumpy.ndarray

Array of BH masses in source frame (Msun).

truncated_normal(size, get_attribute=False, **kwargs)[source]

Sample with a truncated normal distribution.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • x_min: Minimum value, default: 1.0

  • x_max: Maximum value, default: 2.5

  • mu: Mean of the truncated normal distribution, default: 1.4

  • sigma: Standard deviation of the truncated normal distribution, default: 0.68

Returns:
xnumpy.ndarray

Array of values drawn from the truncated normal distribution.

powerlaw(size, get_attribute=False, **kwargs)[source]

Sample values from a normalized power-law distribution. p(x) ∝ x^{-alpha}, x in [x_min, x_max]

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • x_min: Minimum value, default: 0.0

  • x_max: Maximum value, default: 1.0

  • alpha: Power-law index, default: 2.35

Returns:
valuesnumpy.ndarray

Array of values drawn from the normalized power-law distribution.

constant_values_n_size(size=100, get_attribute=False, **kwargs)[source]

Return array of constant values.

Parameters:
sizeint

Number of values to return.

default: 100

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • value: Constant value to return, default: 0.0

Returns:
valuesnumpy.ndarray

Array of constant values.

uniform(size, get_attribute=False, **kwargs)[source]

Sample values from uniform distribution.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

**kwargsdict

Model parameters:

  • x_min: Minimum value, default: 0.0

  • x_max: Maximum value, default: 1.0

Returns:
valuesnumpy.ndarray

Array of uniformly distributed values in range [x_min, x_max].

sampler_cosine(size, get_attribute=False, **kwargs)[source]

Sample from cosine distribution for declination.

Samples values in range [-pi/2, pi/2] following a cosine distribution, appropriate for isotropic sky position declination.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

Returns:
valuesnumpy.ndarray

Array of values in range [-pi/2, pi/2] (rad).

sampler_sine(size, get_attribute=False, **kwargs)[source]

Sample from sine distribution for inclination angles.

Samples values in range [0, pi] following a sine distribution, appropriate for isotropic orientation angles.

Parameters:
sizeint

Number of samples to draw.

get_attributebool

If True, return the sampler object instead of samples.

default: False

Returns:
valuesnumpy.ndarray

Array of values in range [0, pi] (rad).