Struct cont_arith_code::distribution::gaussian::Gaussian
source · pub struct Gaussian {
pub s0: usize,
pub s1: i64,
pub s2: u128,
pub ddof: u8,
pub mean: f64,
pub stdev: f64,
}
Expand description
Numerically stable Gaussian distribution
Fields§
§s0: usize
Number of values
s1: i64
Sum of values
s2: u128
Sum of squares
ddof: u8
0
if values are population, 1
if sample
mean: f64
s1 / s0
stdev: f64
sqrt( (s2 - (s1^2)/s0) / s0 - ddof )
Implementations§
source§impl Gaussian
impl Gaussian
pub fn variance(&self) -> f64
sourcepub fn mle<I>(data: I, ddof: u8) -> Self
pub fn mle<I>(data: I, ddof: u8) -> Self
One pass fit (Max Likelihood Estimation) of a Gaussian to given data, given the desired delta-degree-of-freedom (0 if data is the whole population, 1 if data is a sample)
pub fn log_pdf(&self, x: f64) -> f64
sourcepub fn log_survival(&self, x: f64) -> f64
pub fn log_survival(&self, x: f64) -> f64
Log of the complement of the CDF of the normal
sourcepub fn log_probability(&self, lo: f64, hi: f64) -> f64
pub fn log_probability(&self, lo: f64, hi: f64) -> f64
Returns a numerically stable log(abs(cdf(hi) - cdf(lo)))
pub fn quantile(&self, cp: f64) -> f64
sourcepub fn q_cdf(&self, q: usize, x: f64) -> usize
pub fn q_cdf(&self, q: usize, x: f64) -> usize
Returns the index of the bin from a division of the curve into
q
subsets of equal probability
sourcepub fn q_quantile(&self, q: usize, i: usize) -> f64
pub fn q_quantile(&self, q: usize, i: usize) -> f64
Returns the i
’th q
’tile of self, i.e. the value at the
boundary between the i
th and the i+1
th bin of equal 1/q
probability for this Gaussian. Input i
should be between 1
and q-1
for a real value: i=0
will return
f64::NEG_INFINITY
and i=q
will return f64::INFINITY
. Call
with q*2
and i*2 + 1
to get the middle of the bin above the
boundary
sourcepub fn lerp(&self, lo: f64, hi: f64, cp: f64) -> f64
pub fn lerp(&self, lo: f64, hi: f64, cp: f64) -> f64
Does a linear interpolation on the area under the curve of the PDF of the gaussian between two points. Does the computation in log-scale so we’re numerically stable in the tails
sourcepub fn definite_integral(&self, lo: f64, hi: f64) -> f64
pub fn definite_integral(&self, lo: f64, hi: f64) -> f64
Definite integral (equiv. to self.cdf(hi) - self.cdf(lo)
)
Trait Implementations§
source§impl PartialEq for Gaussian
impl PartialEq for Gaussian
source§impl PartialOrd for Gaussian
impl PartialOrd for Gaussian
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl UnivariateDistribution for Gaussian
impl UnivariateDistribution for Gaussian
fn truncated(&self) -> Box<dyn TruncatedDistribution>
impl Copy for Gaussian
impl StructuralPartialEq for Gaussian
Auto Trait Implementations§
impl Freeze for Gaussian
impl RefUnwindSafe for Gaussian
impl Send for Gaussian
impl Sync for Gaussian
impl Unpin for Gaussian
impl UnwindSafe for Gaussian
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.