LogPsplines in JAX
Project description
LogPSplinePSD
Log-spline representation of the power spectral density (PSD) in the frequency domain, using penalized B-splines with a discrete penalty on spline coefficients to prevent overfitting.
GitHub Repository: https://github.com/nz-gravity/LogPSplinePSD
Paper: Aimen et al (in preparation)
Overview
LogPSplinePSD implements a Bayesian model for PSD estimation by fitting a log-spline to the periodogram. Main features:
Log-frequency representation: Works on the log-scale of frequencies for numerical stability and improved resolution.
P-spline prior: Applies a discrete difference penalty to log B-spline coefficients, enforcing smoothness in the log-PSD domain [Eilers1996].
Whittle likelihood: Employs Whittle’s approximation for fast likelihood evaluation on periodogram ordinates.
CPU/GPU sampling: Uses NumPyro (JAX) to perform efficient Hamiltonian Monte Carlo inference.
Methodology
The approach follows the P-spline framework for spectral density estimation described by Maturana-Russel & Meyer (2021) [MaturanaRussel2021].
Basis construction Define order-r B-spline basis functions \(B_k(\omega)\), \(k=1,\dots,K+r\), on a grid of interior knots in the log-frequency domain.
Penalized prior Apply a discrete \(D\)th-order difference penalty to the spline coefficients \(\{\beta_k\}\), which induces smoothness in the estimated log-PSD.
Knot placement (optional) For spectra with sharp features, knot locations can be set based on quantiles of the raw periodogram values to allocate flexibility where needed.
4. Model and likelihood The log-PSD is modeled as:
\begin{equation*} \log f(\lambda_l) = \sum_k \beta_k \, B_k(\log \lambda_l) \end{equation*}
Whittle’s approximation for the periodogram \(I_n(\lambda_l)\) yields the log-likelihood:
5. Inference We have two options for inference:
Use Metropolis-Hastings to sample from the posterior distribution of the spline coefficients.
Use NumPyro’s NUTS sampler to jointly sample the spline coefficients.
This fixed-basis P-spline approach avoids reversible-jump MCMC over knot numbers and positions, reducing computational cost while retaining flexibility to capture complex spectral features.
Finally, one can also provide a ‘parametric model’ of the PSD as a function that can then be ‘corrected’ non-parametrically by the spline model. This is useful for cases where a known functional form (e.g., power-law) is expected, but additional flexibility is needed to account for deviations in the data.
Installation
pip install LogPSplinePSD
Basic Usage
See demo.py
Acknowledgements
Part of the NZ-Gravity and International LISA Consortium efforts on gravitational-wave data analysis.
References
Eilers, P. H. C., & Marx, B. D. (1996). Flexible smoothing with B-splines and penalties. Statistical Science, 11(2), 89–121. DOI:10.1214/ss/1038425655.
Maturana-Russel, J., & Meyer, R. (2021). P-spline spectral density estimation with a discrete penalty. arXiv:1905.01832.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logpsplinepsd-0.0.11.tar.gz.
File metadata
- Download URL: logpsplinepsd-0.0.11.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2636c0b55eb177deba23554361cd070c57b93c7590044b349edf119ee8a5ab28
|
|
| MD5 |
24ff9be3aa2daedb694d381ddc3348ef
|
|
| BLAKE2b-256 |
351d41a787b0f31934a4a08de57ed35717dc36479b596e4b9f4809a337b6f5d7
|
Provenance
The following attestation bundles were made for logpsplinepsd-0.0.11.tar.gz:
Publisher:
pypi.yml on nz-gravity/LogPSplinePSD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logpsplinepsd-0.0.11.tar.gz -
Subject digest:
2636c0b55eb177deba23554361cd070c57b93c7590044b349edf119ee8a5ab28 - Sigstore transparency entry: 458286719
- Sigstore integration time:
-
Permalink:
nz-gravity/LogPSplinePSD@ca62dfb889af5cb20fe938a7046bf4c1c4aa522a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nz-gravity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@ca62dfb889af5cb20fe938a7046bf4c1c4aa522a -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file logpsplinepsd-0.0.11-py3-none-any.whl.
File metadata
- Download URL: logpsplinepsd-0.0.11-py3-none-any.whl
- Upload date:
- Size: 52.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7183f2c027c4e51babd8a21c31b88a42c62e4b31b29b443e9110990d37787f72
|
|
| MD5 |
1428909c20e3e23d8c9ffd9b47ec248d
|
|
| BLAKE2b-256 |
e99fb745f791e16c3653a5bbe9f40669b2aa6373e1a44b6cbdc760bf5201e01a
|
Provenance
The following attestation bundles were made for logpsplinepsd-0.0.11-py3-none-any.whl:
Publisher:
pypi.yml on nz-gravity/LogPSplinePSD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logpsplinepsd-0.0.11-py3-none-any.whl -
Subject digest:
7183f2c027c4e51babd8a21c31b88a42c62e4b31b29b443e9110990d37787f72 - Sigstore transparency entry: 458286721
- Sigstore integration time:
-
Permalink:
nz-gravity/LogPSplinePSD@ca62dfb889af5cb20fe938a7046bf4c1c4aa522a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nz-gravity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@ca62dfb889af5cb20fe938a7046bf4c1c4aa522a -
Trigger Event:
workflow_run
-
Statement type: