pub struct Beta {
pub alpha: f64,
pub beta: f64,
}Expand description
Beta distribution Beta(α, β).
§Examples
use rs_stats::distributions::beta::Beta;
use rs_stats::distributions::traits::Distribution;
let b = Beta::new(2.0, 5.0).unwrap();
assert!((b.mean() - 2.0 / 7.0).abs() < 1e-10);Fields§
§alpha: f64Shape parameter α > 0
beta: f64Shape parameter β > 0
Implementations§
Source§impl Beta
impl Beta
Sourcepub fn new(alpha: f64, beta: f64) -> StatsResult<Self>
pub fn new(alpha: f64, beta: f64) -> StatsResult<Self>
Creates a Beta(α, β) distribution. Both parameters must be positive.
Sourcepub fn fit(data: &[f64]) -> StatsResult<Self>
pub fn fit(data: &[f64]) -> StatsResult<Self>
MLE via method of moments from data in [0, 1].
Requires all data in (0, 1). Estimates α and β from sample mean and variance.
Trait Implementations§
Source§impl Distribution for Beta
impl Distribution for Beta
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Number of free parameters (used when computing AIC / BIC).
Source§fn inverse_cdf(&self, p: f64) -> StatsResult<f64>
fn inverse_cdf(&self, p: f64) -> StatsResult<f64>
Quantile (inverse CDF): find x such that F(x) = p.
Source§fn log_likelihood(&self, data: &[f64]) -> StatsResult<f64>
fn log_likelihood(&self, data: &[f64]) -> StatsResult<f64>
Sum of log-likelihoods: Σ ln f(xᵢ).
impl Copy for Beta
Auto Trait Implementations§
impl Freeze for Beta
impl RefUnwindSafe for Beta
impl Send for Beta
impl Sync for Beta
impl Unpin for Beta
impl UnsafeUnpin for Beta
impl UnwindSafe for Beta
Blanket Implementations§
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
Mutably borrows from an owned value. Read more