sigway.binned_pzeta¶
A model-independent spectrum: \(\mathcal{P}_\zeta(k)\) is represented as free
\(\log_{10}\) amplitudes in \(k\)-bins. Binned_P_zeta returns \(\Omega_{\mathrm{GW}}\) directly
from precomputed coefficients (no kernel, no \((s,t)\) integral) but exposes the same
interface as OmegaGW.
Model¶
sigway.binned_pzeta.Binned_P_zeta ¶
Model-independent gravitational-wave spectrum from a binned primordial curvature power spectrum \(\mathcal{P}_\zeta(k)\).
Physical idea. Instead of assuming a fixed shape for \(\mathcal{P}_\zeta(k)\) (e.g. a log-normal or power law), this class represents it as free, independent amplitudes in \(n\) logarithmically spaced wavenumber bins. Each bin \(i\) carries a single free parameter \(\theta_i \equiv \log_{10} A_i\), so the linear amplitude in that bin is \(A_i = 10^{\theta_i}\). The resulting scalar-induced GW energy-density spectrum is
where \(C_{mij}\) are precomputed bilinear coefficients that fold in the GW kernel and the \((s,t)\) transfer-function integral once and for all. Evaluating the spectrum then reduces to a single tensor contraction — much cheaper than computing the full kernel integral at every likelihood call. This makes the class well suited for model-independent reconstruction of \(\mathcal{P}_\zeta(k)\) from GW data, and for computing Fisher forecasts without committing to a spectral shape.
Interface. The public API is identical to
OmegaGW: parameter_names returns the
ordered parameter tuple, the instance is callable as model(f, *theta)
to obtain \(\Omega_{\mathrm{GW}}(f)\), and jacobian(f, theta) returns
the gradient matrix needed by Fisher/MCMC codes.
Attributes:
| Name | Type | Description |
|---|---|---|
fk |
ndarray
|
Output frequency grid (in units of \(k = 2\pi f\)) on which the coefficient tensor \(C_{mij}\) is tabulated. |
fp |
ndarray
|
Wavenumber grid of the \(\mathcal{P}_\zeta\) bins (centres of the \(n\) input bins). |
C_mij |
ArrayImpl
|
Precomputed bilinear coefficient tensor, shape
|
knum |
int
|
Number of output frequency bins (length of |
pnum |
int
|
Number of \(\mathcal{P}_\zeta\) bins (length of |
parameterNames |
dict
|
Ordered mapping of parameter names to their LaTeX labels,
e.g. |
norm |
callable
|
Normalisation prefactor \(\mathcal{N}(k)\) applied to
\(\Omega_{\mathrm{GW}}\); set at construction time (see |
d1 |
callable
|
Alias for |
Examples:
Excite a single bin near the middle of the spectrum and evaluate \(\Omega_{\mathrm{GW}}(f)\):
>>> import jax.numpy as jnp
>>> from sigway.binned_pzeta import Binned_P_zeta
>>> model = Binned_P_zeta("binned", "Binned", nbins=100)
>>> amps = [-4.0] * len(model.parameter_names) # log10 amplitudes
>>> amps[50] = 0.0 # excite one bin
>>> omega = model(jnp.geomspace(2e-5, 1.0, 80), *amps)
Load precomputed bilinear coefficients and set up the spectral model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Short internal identifier for the model (stored as
|
required |
model_label
|
str
|
Human-readable display name for the model (stored as
|
required |
nbins
|
int
|
Number of logarithmically spaced \(\mathcal{P}_\zeta(k)\) bins.
Precomputed coefficient files ship with the package for
|
50
|
path_to_C
|
str or None
|
Path to a custom coefficient file (plain text, SIGWAY format)
containing \(C_{mij}\), \(f_k\), and \(f_p\). When |
None
|
norm
|
str or callable
|
Overall normalisation prefactor \(\mathcal{N}\) applied to \(\Omega_{\mathrm{GW}}\).
|
'RD'
|
backend
|
str
|
Computation backend. Currently only |
'jax'
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no coefficient file is found for the requested |
parameter_names
property
¶
Ordered names of the \(\mathcal{P}_\zeta\) bin parameters.
Returns a tuple ('A_0', 'A_1', ..., 'A_{n-1}') where \(n\) is the
number of bins. The ordering matches the expected sequence of
\(\theta_i\) values in __call__ and jacobian, and is consistent
with the parameter_names property of
OmegaGW.
Returns:
| Type | Description |
|---|---|
tuple of str
|
Parameter names for the \(\log_{10}\)-amplitude of each \(\mathcal{P}_\zeta\) bin. |
__call__ ¶
Evaluate \(\Omega_{\mathrm{GW}}(f)\) from the bin \(\log_{10}\)-amplitudes.
Thin wrapper around template that satisfies the standard callable
interface shared with OmegaGW: pass a
frequency array and the \(n\) bin parameters \(\theta_i\), receive the GW
energy-density spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Frequencies in Hz at which \(\Omega_{\mathrm{GW}}\) is evaluated. |
required |
*theta
|
float
|
\(\log_{10}\)-amplitudes \(\theta_0, \theta_1, \ldots, \theta_{n-1}\) of the \(\mathcal{P}_\zeta\) bins. |
()
|
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\Omega_{\mathrm{GW}}(f)\) evaluated at each frequency in |
dtemplate_default ¶
Partial derivative of \(\Omega_{\mathrm{GW}}\) with respect to one bin \(\log_{10}\)-amplitude.
Evaluates
\(\partial \Omega_{\mathrm{GW}} / \partial \theta_{\text{index}}\)
analytically. Because \(A_i = 10^{\theta_i}\) and the spectrum is
bilinear in the \(A_i\), the chain rule gives
\(2 \ln(10)\, A_i \sum_j C_{mij}\, A_j\); the factor \(\ln(10) A_i\) is
absorbed into the linear-amplitude convention used here. The result is
interpolated linearly (not log-linearly) to fvec to avoid
problems where the derivative passes through zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
0-based index of the \(\mathcal{P}_\zeta\) bin parameter \(\theta_i\) being differentiated (must be in \([0,\, n)\)). |
required |
fvec
|
array_like
|
Frequencies in Hz at which the derivative is evaluated. |
required |
*A
|
float
|
\(\log_{10}\)-amplitudes \(\theta_0, \ldots, \theta_{n-1}\) of all
\(\mathcal{P}_\zeta\) bins (same convention as |
()
|
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\partial \Omega_{\mathrm{GW}} / \partial \theta_{\text{index}}\)
at each frequency in |
jacobian ¶
Full Jacobian of \(\Omega_{\mathrm{GW}}\) with respect to the bin \(\log_{10}\)-amplitudes \(\theta\).
Calls dtemplate_default for every bin index and stacks the
results into a matrix, following the same interface as
OmegaGW. The Jacobian is used by Fisher
forecasting and gradient-based samplers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Frequencies in Hz at which the Jacobian is evaluated. |
required |
theta
|
array_like
|
\(\log_{10}\)-amplitudes of all \(\mathcal{P}_\zeta\) bins,
shape |
required |
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
Array of shape |
template ¶
Evaluate \(\Omega_{\mathrm{GW}}(f)\) on an arbitrary frequency grid.
Converts the supplied \(\log_{10}\)-amplitudes \(\theta_i\) to linear
amplitudes \(A_i = 10^{\theta_i}\), contracts them against the
precomputed tensor \(C_{mij}\) to obtain \(\Omega_{\mathrm{GW}}\) on the
internal grid fk, then log-linearly interpolates to the requested
output frequencies. The result is multiplied by the normalisation
prefactor self.norm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fvec
|
array_like
|
Frequencies in Hz at which \(\Omega_{\mathrm{GW}}\) is evaluated. |
required |
*A
|
float
|
\(\log_{10}\)-amplitudes \(\theta_0, \theta_1, \ldots, \theta_{n-1}\)
of the \(\mathcal{P}_\zeta\) bins. The linear amplitude in bin \(i\)
is \(10^{A_i}\). The number of values must equal |
()
|
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\Omega_{\mathrm{GW}}\) evaluated at each frequency in |
Helper functions¶
sigway.binned_pzeta.compute_omega_gw ¶
Contract the precomputed coefficient tensor with the bin amplitudes.
Evaluates \(\Omega_{\mathrm{GW}}[m] = \sum_{i,j} C_{mij}\, A_i A_j\) on the internal frequency grid using a single tensor contraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
C_mij
|
ArrayImpl
|
Bilinear coefficient tensor of shape |
required |
A
|
ArrayImpl
|
Linear bin amplitudes, shape |
required |
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
Un-normalised \(\Omega_{\mathrm{GW}}\) on the internal frequency grid,
shape |
sigway.binned_pzeta.compute_domega_gw ¶
Partial derivative of the GW spectrum with respect to one bin amplitude.
Evaluates \(\partial \Omega_{\mathrm{GW}}[m] / \partial A_i = 2 \sum_j C_{mij}\, A_j\) on the internal frequency grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
C_mij
|
ArrayImpl
|
Bilinear coefficient tensor of shape |
required |
i
|
int
|
Index of the bin amplitude being differentiated (0-based). |
required |
A
|
ArrayImpl
|
Linear bin amplitudes \(A_j = 10^{\theta_j}\), shape |
required |
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\partial \Omega_{\mathrm{GW}} / \partial A_i\) on the internal
frequency grid, shape |
sigway.binned_pzeta.upsample_f ¶
Interpolate \(\Omega_{\mathrm{GW}}\) to a new frequency grid (log–log).
Performs log-linear interpolation: both the frequency axis and
\(\Omega_{\mathrm{GW}}\) are treated in \(\log_{10}\), so the result is
power-law accurate between grid points. Frequencies outside fk
are extrapolated to \(10^{-30}\) (effectively zero).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Target frequencies at which to evaluate \(\Omega_{\mathrm{GW}}\). |
required |
fk
|
array_like
|
Internal frequency grid (must be sorted ascending). |
required |
Omega_GW
|
array_like
|
\(\Omega_{\mathrm{GW}}\) values on |
required |
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\Omega_{\mathrm{GW}}\) interpolated to |
sigway.binned_pzeta.upsample_f_binned ¶
Resample \(\Omega_{\mathrm{GW}}\) with nearest-bin (step) interpolation.
Holds \(\Omega_{\mathrm{GW}}\) constant within each bin of fk, so the
result is a piecewise-constant (staircase) function. Useful when the
output should preserve the bin structure rather than blend between bins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Target frequencies. |
required |
fk
|
array_like
|
Internal frequency-bin edges (sorted ascending). |
required |
Omega_GW
|
array_like
|
\(\Omega_{\mathrm{GW}}\) values, one per bin in |
required |
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\Omega_{\mathrm{GW}}\) at each frequency in |
sigway.binned_pzeta.upsample_f_linear ¶
Interpolate \(\Omega_{\mathrm{GW}}\) to a new frequency grid (linear).
Plain linear interpolation — no logarithm taken on either axis. Used for derivatives, where \(\Omega_{\mathrm{GW}}\) can pass through zero and a log-space interpolation would be undefined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Target frequencies. |
required |
fk
|
array_like
|
Internal frequency grid (sorted ascending). |
required |
Omega_GW
|
array_like
|
\(\Omega_{\mathrm{GW}}\) values on |
required |
Returns:
| Type | Description |
|---|---|
ArrayImpl
|
\(\Omega_{\mathrm{GW}}\) linearly interpolated to |