allan-tools
Allantools (python lib) portage to Rust
This library allows easy computations of Allan deviation & similar statistics.
These statistical methods are mostly used in system stability studies.
Variances / Deviations
Compute Allan deviation over raw data:
use *;
let taus = generator; // [2, 4, 8, ... 128]
let sampling_period = 1.0_f64; // [s]
let = deviation.unwrap;
This lib against stable32 on a well known signal.
Error bars
Only basic (biased) error bars following the 1/√N decay are currently produced
Overlapping
Improve statiscal confidence by using overlapped formulae
let data: = some_data;
let taus = generator;
let overlapping = true;
let sampling_period = 1.0_f64; // [s]
let = deviation.unwrap;
Fractionnal data
is fractional can be used to compute statistics over fractional
(n.a) data:
let data: = some_data;
let taus = generator;
let is_fractional = true;
let sampling_period = 1.0_f64; // [s]
let = deviation.unwrap;
let = deviation.unwrap;
Tau axis generator
The user can pass any τ serie to all computation methods.
This lib integrates a τ axis generator too, which is a convenient method to quickly pass a standard axis to a computation method. Several axis are known:
- TauAxis::Octave is the most efficient
- TauAxis::Decade is the standard and is efficient
- TauAxis::All requires more computation
let taus = generator; // [1.0, 10.0, 100.0, ..., 10000.0]
Using TauAxis::All requires more computation but gives a total time granularity
let taus = generator; // [1.0, 2.0, 3.0, ..., 99.0, 100.0]
Tau offset and error management
This library computes the requested statistics for all τ values, as long as
$#964;(n) can be evaluated.
If τ (n) cannot be evaluated, computation stops and returns all
previously evaluated offsets.
If not a single τ value is feasible, the lib returns Error::NotEnoughSamplesError
The user must pass a valid τ serie, otherwise:
- TauAxis::NullTauValue: is returned when τ = 0 (non sense) is requested
- TauAxis::NegativeTauValue: is return when τ < 0 (non physical) is requested
- TauAxis::InvalidTauShape: shape is not an increasing (not necessarily steady) shape
Data & Noise generators
Some data generators were integrated or develpped for testing purposes:
- White noise generator
let x = white_noise; // 10k samples
- Pink noise generator
let x = pink_noise; // 1k samples
| Noise | White PM | Flicker PM | White FM | Flicker FM |
|---|---|---|---|---|
| adev | -1 | -1 | -1/2 | 0 |
| mdev | -3/2 | -1 | -1/2 | 0 |
| method | utils::diff(noise::white) | utils::diff(noise::pink) | noise::white | noise::pink |
Power Law Identification
NIST LAG1D autocorrelation
NIST Power Law identification method[[46]]
This macro works well on data serie where one noise process is very dominant.
let r = nist_lag1d_autocorr;
Bias1 + R(n) identification method
TODO
Three Cornered Hat
Three cornered hat fashion statistics, to estimate a/b/c from a against b, b against c and c against a measurements.
let a_against_b = some_measurements;
let b_against_c = some_measurements;
let c_against_a = some_measurements;
let taus = tau_generator;
let sampling_period = 1.0;
let is_fractionnal = false;
let overlapping = true;
let =
three_cornered_hat.unwrap;
Tools & utilities
cumsum : (python::numpy like) returns cummulative sum of a serie
let data: = some_data;
cumsum;
cumsum; // opt. normalization
diff : (python::numpy like) returns 1st order derivative of a serie
let data: = some_data;
diff;
diff; // opt. normalization
random : generates a pseudo random sequence 0 < x <= 1.0
let data = random; // 1k symbols
println!;
normalize : normalizes a sequence to 1/norm :
let data: = somedata;
let normalized = normalize; // 1/(2pi)
to_fractional_frequency : converts a raw data serie to fractional data.
let data: = somedata; // sampled @ 10kHz
let fract = to_fractional_frequency; // :)
fractional_integral : converts a serie of fractional measurements to integrated measurements (like fractional frequency (n.a) to phase time (s)).
let data: = somedata; // (n.a)
let fract = fractional_integral; // sampled @ 1Hz :)
fractional_freq_to_phase_time : macro wrapper of previous function
phase_to_radians : converts phase time (s) to phase radians (rad)
let data: = somedata; // (s)
let data_rad = phase_to_radians;