Struct statrs::distribution::StudentsT [−][src]
pub struct StudentsT { /* fields omitted */ }Implements the Student’s T distribution
Examples
use statrs::distribution::{StudentsT, Continuous}; use statrs::statistics::Mean; use statrs::prec; let n = StudentsT::new(0.0, 1.0, 2.0).unwrap(); assert_eq!(n.mean(), 0.0); assert!(prec::almost_eq(n.pdf(0.0), 0.353553390593274, 1e-15));
Implementations
impl StudentsT[src]
impl StudentsT[src]pub fn new(location: f64, scale: f64, freedom: f64) -> Result<StudentsT>[src]
Constructs a new student’s t-distribution with location location,
scale scale,
and freedom freedom.
Errors
Returns an error if any of location, scale, or freedom are NaN.
Returns an error if scale <= 0.0 or freedom <= 0.0
Examples
use statrs::distribution::StudentsT; let mut result = StudentsT::new(0.0, 1.0, 2.0); assert!(result.is_ok()); result = StudentsT::new(0.0, 0.0, 0.0); assert!(result.is_err());
pub fn location(&self) -> f64[src]
Returns the location of the student’s t-distribution
Examples
use statrs::distribution::StudentsT; let n = StudentsT::new(0.0, 1.0, 2.0).unwrap(); assert_eq!(n.location(), 0.0);
pub fn scale(&self) -> f64[src]
Returns the scale of the student’s t-distribution
Examples
use statrs::distribution::StudentsT; let n = StudentsT::new(0.0, 1.0, 2.0).unwrap(); assert_eq!(n.scale(), 1.0);
pub fn freedom(&self) -> f64[src]
Returns the freedom of the student’s t-distribution
Examples
use statrs::distribution::StudentsT; let n = StudentsT::new(0.0, 1.0, 2.0).unwrap(); assert_eq!(n.freedom(), 2.0);
Trait Implementations
impl CheckedEntropy<f64> for StudentsT[src]
impl CheckedEntropy<f64> for StudentsT[src]fn checked_entropy(&self) -> Result<f64>[src]
impl CheckedMean<f64> for StudentsT[src]
impl CheckedMean<f64> for StudentsT[src]impl CheckedSkewness<f64> for StudentsT[src]
impl CheckedSkewness<f64> for StudentsT[src]impl CheckedVariance<f64> for StudentsT[src]
impl CheckedVariance<f64> for StudentsT[src]fn checked_variance(&self) -> Result<f64>[src]
Returns the variance of the student’s t-distribution
Errors
If freedom <= 1.0
Formula
if v == INF { σ^2 } else if freedom > 2.0 { v * σ^2 / (v - 2) } else { INF }
where σ is the scale and v is the freedom
fn checked_std_dev(&self) -> Result<f64>[src]
impl Continuous<f64, f64> for StudentsT[src]
impl Continuous<f64, f64> for StudentsT[src]fn pdf(&self, x: f64) -> f64[src]
Calculates the probability density function for the student’s
t-distribution
at x
Formula
Γ((v + 1) / 2) / (sqrt(vπ) * Γ(v / 2) * σ) * (1 + k^2 / v)^(-1 / 2 * (v + 1))
where k = (x - μ) / σ, μ is the location, σ is the scale, v is
the freedom,
and Γ is the gamma function
fn ln_pdf(&self, x: f64) -> f64[src]
Calculates the log probability density function for the student’s
t-distribution
at x
Formula
ln(Γ((v + 1) / 2) / (sqrt(vπ) * Γ(v / 2) * σ) * (1 + k^2 / v)^(-1 / 2 * (v + 1)))
where k = (x - μ) / σ, μ is the location, σ is the scale, v is
the freedom,
and Γ is the gamma function
impl Distribution<f64> for StudentsT[src]
impl Distribution<f64> for StudentsT[src]impl Univariate<f64, f64> for StudentsT[src]
impl Univariate<f64, f64> for StudentsT[src]fn cdf(&self, x: f64) -> f64[src]
Calculates the cumulative distribution function for the student’s
t-distribution
at x
Formula
if x < μ { (1 / 2) * I(t, v / 2, 1 / 2) } else { 1 - (1 / 2) * I(t, v / 2, 1 / 2) }
where t = v / (v + k^2), k = (x - μ) / σ, μ is the location,
σ is the scale, v is the freedom, and I is the regularized
incomplete
beta function
impl Variance<f64> for StudentsT[src]
impl Variance<f64> for StudentsT[src]