Skip to main content

jarque_bera

Function jarque_bera 

Source
pub fn jarque_bera<T: Float, I: IntoIterator<Item = T>>(
    data: I,
) -> Result<Computation<T>, Error>
Expand description

Performs the Jarque-Bera test for normality.

The test determines whether sample data have skewness and kurtosis matching a normal distribution.

The test statistic is calculated based on the sample’s skewness and excess kurtosis. Under the null hypothesis of normality, this statistic follows a chi-squared distribution with 2 degrees of freedom.

Takes one argument data which is an iterator over floating-point numbers (impl IntoIterator<Item = T>).

The sample size of data must be greater than or equal to 3. Also, the range of data must not be equal to 0.

§Examples

use normality::jarque_bera;

let normal_data = vec![-1.1, 0.2, -0.4, 0.0, -0.7, 1.2, -0.1, 0.8, 0.5, -0.9];
let result = jarque_bera(normal_data).unwrap();
// p-value should be high for normal data
assert!(result.p_value > 0.05);

let uniform_data =
    vec![2.0, 2.0, 2.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0];
let result_uniform = jarque_bera(uniform_data).unwrap();
// p-value should be low for non-normal data
assert!(result_uniform.p_value < 0.05);