Skip to content

Sampling and Spectra

These standalone helpers complement the main model class and are most useful when post-processing sampled realizations.

draw_parameters

draw_parameters(param_ranges=None, key=None)

Draw one random semi-analytic population parameter set.

This helper samples each model parameter independently from a broad range motivated by the original semi-analytic model literature and related posterior explorations. It is mainly intended for toy scans, demonstrations, and stochastic parameter studies rather than for calibrated inference.

Parameters:

  • param_ranges (dict, default: None ) –

    Mapping from parameter name to [min, max] interval. The parameters are n0, alphaM, Mstar, betaz, and z0. n0 and Mstar are sampled uniformly in log-space; the others are sampled uniformly in linear space.

  • key (PRNGKey or int, default: None ) –

    Random key or integer seed. If None, a fresh nondeterministic key is generated internally.

Returns:

  • dict

    Dictionary containing one sampled parameter set with scalar Python values ready to pass into SemiAnalyticPopulation.

h

h(M, f, z)

Compute the source strain amplitude without angular averaging.

The normalization used throughout the package is

\[ h(\mathcal{M}, f, z) = \frac{4\pi^{2/3}(G\mathcal{M})^{5/3}}{c^4 D_c(z)} \left[f(1+z)\right]^{2/3}, \]

with \(D_c(z)\) the comoving distance. This quantity is appropriate for source-level calculations before averaging over sky position and binary orientation.

h_average

h_average(M, f, z)

Compute the sky-and-orientation averaged strain amplitude.

fastropop uses the stochastic-background convention

\[ \bar h(\mathcal{M}, f, z) = \sqrt{\frac{2}{5}}\, h(\mathcal{M}, f, z), \]

which is the amplitude entering the Monte Carlo binning of unresolved populations.

dlnfdtr

dlnfdtr(M, f, z)

Compute the GW-driven frequency evolution \(d\ln f_r / dt_r\).

The semi-analytic model assumes binaries evolve only through quadrupolar gravitational-wave emission. In that limit,

\[ \frac{d \ln f_r}{dt_r} = \frac{96}{5}\pi^{8/3} \frac{(G \mathcal{M})^{5/3}}{c^5} f_r^{8/3}, \]

where \(\mathcal{M}\) is the chirp mass and \(f_r = (1+z) f\) is the rest-frame GW frequency.

Parameters:

  • M (float or Array) –

    Chirp mass in kilograms.

  • f (float or Array) –

    Observer-frame GW frequency in Hz.

  • z (float or Array) –

    Redshift.

Returns:

  • float or Array

    Frequency-evolution term in \({\rm s^{-1}}\).

compute_h

compute_h(distM, distz, f_obs)

Compute source strain amplitudes for sampled masses and redshifts.

Parameters:

  • distM (array - like) –

    Sampled chirp masses in the sampling convention of the package, i.e. masses expressed in units of kilograms divided by fastropop.kg.

  • distz (array - like) –

    Sampled redshifts.

  • f_obs (float or array - like) –

    Observer-frame GW frequency in Hz.

Returns:

  • Array

    Source strain amplitudes evaluated with h.

binning

binning(distM, distz, distlog10f, freqs=None, hc2_values=None, do_plot=True)

Bin one Monte Carlo realization into PTA-style frequency bins.

For each sampled source, the code computes the averaged strain \(\bar h\), forms \(f \bar h^2\), assigns the source to a PTA frequency bin, and sums the contributions in that bin. The returned spectrum therefore represents the discretized realization of the stochastic background before taking the final square root for plotting as \(h_c(f)\).

Parameters:

  • distM (array - like) –

    Sampled chirp masses in package sampling units (kg-scaled).

  • distz (array - like) –

    Sampled redshifts.

  • distlog10f (array - like) –

    Sampled \(\log_{10} f\) values, with \(f\) in Hz.

  • freqs (array - like, default: None ) –

    Smooth reference frequency grid for the optional diagnostic plot.

  • hc2_values (array - like, default: None ) –

    Smooth reference characteristic-strain curve for the optional plot.

  • do_plot (bool, default: True ) –

    If True, call fastropop.plot_binned_spectrum.

Returns:

  • Array

    Array of shape (n_bins, 2) with columns [log10(f_bin_center), summed_bin_value].