probability/distribution/
mod.rs1use alloc::vec::Vec;
4#[allow(unused_imports)]
5use special::Primitive;
6
7use source::Source;
8
9pub trait Continuous: Distribution {
11 fn density(&self, x: f64) -> f64;
13}
14
15pub trait Discrete: Distribution {
17 fn mass(&self, x: Self::Value) -> f64;
19}
20
21pub trait Distribution {
23 type Value;
25
26 fn distribution(&self, x: f64) -> f64;
28}
29
30pub trait Entropy: Distribution {
32 fn entropy(&self) -> f64;
36}
37
38pub trait Inverse: Distribution {
40 fn inverse(&self, p: f64) -> Self::Value;
42}
43
44pub trait Kurtosis: Skewness {
46 fn kurtosis(&self) -> f64;
48}
49
50pub trait Mean: Distribution {
54 fn mean(&self) -> f64;
56}
57
58pub trait Median: Distribution {
62 fn median(&self) -> f64;
64}
65
66pub trait Modes: Distribution {
70 fn modes(&self) -> Vec<Self::Value>;
72}
73
74pub trait Sample: Distribution {
76 fn sample<S>(&self, source: &mut S) -> Self::Value
78 where
79 S: Source;
80}
81
82pub trait Skewness: Variance {
84 fn skewness(&self) -> f64;
86}
87
88pub trait Variance: Mean {
92 fn variance(&self) -> f64;
94
95 #[inline(always)]
97 fn deviation(&self) -> f64 {
98 self.variance().sqrt()
99 }
100}
101
102mod bernoulli;
103mod beta;
104mod binomial;
105mod categorical;
106mod cauchy;
107mod exponential;
108mod gamma;
109mod gaussian;
110mod laplace;
111mod logistic;
112mod lognormal;
113mod pert;
114mod triangular;
115mod uniform;
116
117pub use self::bernoulli::Bernoulli;
118pub use self::beta::Beta;
119pub use self::binomial::Binomial;
120pub use self::categorical::Categorical;
121pub use self::cauchy::Cauchy;
122pub use self::exponential::Exponential;
123pub use self::gamma::Gamma;
124pub use self::gaussian::Gaussian;
125pub use self::laplace::Laplace;
126pub use self::logistic::Logistic;
127pub use self::lognormal::Lognormal;
128pub use self::pert::Pert;
129pub use self::triangular::Triangular;
130pub use self::uniform::Uniform;