Skip to content

MWhitta/sciencefacts

Repository files navigation

sciencefacts

Utilities for inspecting numeric data files and collecting metadata. The package centres around the :class:~data_signal.Signal helper which provides tools for estimating noise levels and assessing distributional properties of 1‑D data.

Noise level estimation

Signal.noise_levels() implements three median–absolute–deviation based estimators: first differences, second differences and a Haar wavelet detail coefficient approach. The function returns absolute and relative noise levels for each estimator.

from data_signal import Signal

# ``data`` is a 1-D sequence
sig = Signal(data)
print(sig.noise_levels())

The figure below shows a noisy sine wave together with the estimated standard deviation from the first-difference method.

Noise level estimation demo

Unimodality tests

To determine whether a sample comes from a multimodal distribution the Signal.multimodality method applies Hartigan's dip test and, only when the dip test indicates possible multimodality, Silverman's critical bandwidth test. Hartigan's test uses a bootstrap from the uniform distribution whereas the Silverman test relies on a normal bootstrap; both return statistics and p-values along with a boolean is_multimodal flag (Silverman's entry contains NaNs when the test is skipped).

from data_signal import Signal

sig = Signal(data)
print(sig.multimodality(num_bootstrap=200))

The example compares a unimodal normal sample with a clearly bimodal mixture; multimodality correctly flags the latter as multimodal.

Unimodality tests demo

Installation

Install the project and its runtime dependencies with:

pip install .

For development and running the test suite, include the optional test dependencies:

pip install .[test]

Testing

Run unit tests with:

pytest

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors