Skip to main content

normal_pdf_batch

Function normal_pdf_batch 

Source
pub fn normal_pdf_batch<F>(
    x: &ArrayView1<'_, F>,
    mean: F,
    std_dev: F,
) -> StatsResult<Array1<F>>
Expand description

Evaluate the Normal PDF at each point in x using SIMD.

Computes the probability density

f(x) = exp(−(x − μ)² / (2σ²)) / (σ √(2π))

over an entire array in a single vectorised pass.

§Arguments

  • x — Points at which to evaluate.
  • mean — Distribution mean µ.
  • std_dev — Distribution standard deviation σ (must be positive).

§Errors

Returns StatsError::InvalidArgument when std_dev <= 0 or x is empty.

§Examples

use scirs2_core::ndarray::array;
use scirs2_stats::normal_pdf_batch;

let x = array![0.0_f64, 1.0, -1.0];
let pdf = normal_pdf_batch(&x.view(), 0.0, 1.0).expect("failed");
// pdf(0) ≈ 0.3989
assert!((pdf[0] - 0.3989422804_f64).abs() < 1e-8);