pub struct JarqueBera { /* private fields */ }Expand description
Jarque-Bera — the Jarque-Bera test statistic measuring how far a window’s distribution departs from normal, via its skewness and excess kurtosis.
S = skewness = m3 / m2^(3/2)
K = excess kurtosis = m4 / m2² − 3
JB = (period / 6) · ( S² + K²/4 )where m2, m3, m4 are the second, third and fourth central moments of the
window. A perfectly normal sample has zero skew and zero excess kurtosis, so
JB = 0; the statistic grows as the distribution becomes asymmetric (non-zero
skew) or fat- or thin-tailed (non-zero excess kurtosis). Under the null of
normality JB is asymptotically χ² with two degrees of freedom, so values
above roughly 6 reject normality at the 95% level — a useful streaming flag
for fat-tail / crash-risk regimes in a return series.
The statistic is ≥ 0. A degenerate window with zero variance (m2 == 0)
returns 0. The first value lands after period inputs; each update
recomputes the four moments over the window in O(period).
§Example
use wickra_core::{Indicator, JarqueBera};
let mut indicator = JarqueBera::new(50).unwrap();
let mut last = None;
for i in 0..80 {
last = indicator.update((f64::from(i) * 0.3).sin());
}
assert!(last.is_some());Implementations§
Source§impl JarqueBera
impl JarqueBera
Sourcepub fn new(period: usize) -> Result<Self>
pub fn new(period: usize) -> Result<Self>
Construct a rolling Jarque-Bera over period values.
§Errors
Returns Error::PeriodZero if period == 0 and
Error::InvalidPeriod if period < 4 (the statistic is degenerate on
fewer than four points).
Trait Implementations§
Source§impl Clone for JarqueBera
impl Clone for JarqueBera
Source§fn clone(&self) -> JarqueBera
fn clone(&self) -> JarqueBera
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JarqueBera
impl Debug for JarqueBera
Source§impl Indicator for JarqueBera
impl Indicator for JarqueBera
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for JarqueBera
impl RefUnwindSafe for JarqueBera
impl Send for JarqueBera
impl Sync for JarqueBera
impl Unpin for JarqueBera
impl UnsafeUnpin for JarqueBera
impl UnwindSafe for JarqueBera
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BatchNanExt for T
impl<T> BatchNanExt for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more