The Erlang struct implements the Erlang distribution, which is a special case of the Gamma distribution. It can be used to calculate probability density functions (PDF), cumulative distribution functions (CDF), and various statistical properties like mean, variance, and entropy.
To use it, construct an instance using Erlang::new(shape, rate).
Parameters
shape (k): A u64 representing the shape parameter.rate (λ): An f64 representing the rate parameter.
Errors
Erlang::new returns a GammaError if:
shape or rate are NaN.shape is 0.rate is <= 0.0.
use statrs::distribution::{Erlang, Continuous};
use statrs::statistics::Distribution;
use approx::assert_abs_diff_eq;
let n = Erlang::new(3, 1.0).unwrap();
assert_eq!(n.mean().unwrap(), 3.0);
assert_abs_diff_eq!(n.pdf(2.0), 0.270670566473225383788, epsilon = 1e-15);