Struct statrs::distribution::StudentsT [−][src]
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]
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]
fn checked_entropy(&self) -> Result<f64>
[src]
impl CheckedMean<f64> for StudentsT
[src]
fn checked_mean(&self) -> Result<f64>
[src]
impl CheckedSkewness<f64> for StudentsT
[src]
fn checked_skewness(&self) -> Result<f64>
[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 Clone 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 Copy for StudentsT
[src]
impl Debug for StudentsT
[src]
impl Distribution<f64> for StudentsT
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
pub fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
R: Rng,
impl Entropy<f64> for StudentsT
[src]
impl Max<f64> for StudentsT
[src]
fn max(&self) -> f64
[src]
Returns the maximum value in the domain of the student’s t-distribution representable by a double precision float
Formula
INF
impl Mean<f64> for StudentsT
[src]
impl Median<f64> for StudentsT
[src]
impl Min<f64> for StudentsT
[src]
fn min(&self) -> f64
[src]
Returns the minimum value in the domain of the student’s t-distribution representable by a double precision float
Formula
-INF
impl Mode<f64> for StudentsT
[src]
impl PartialEq<StudentsT> for StudentsT
[src]
impl Skewness<f64> for StudentsT
[src]
impl StructuralPartialEq 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]
Auto Trait Implementations
impl RefUnwindSafe for StudentsT
impl Send for StudentsT
impl Sync for StudentsT
impl Unpin for StudentsT
impl UnwindSafe for StudentsT
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,