Distribution
All continuous distribution implements the Continuous trait
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
use crate::algebra::abstr::Real;
use std::iter;
pub trait Distribution<T>
where
T: Real,
{
fn random(&self) -> T;
fn random_sequence(&self, size: u32) -> Vec<T> {
let mut v: Vec<T> = Vec::new();
v.extend(iter::repeat_with(&|| self.random()).take(size as usize));
v
}
}
/// Continuous distribution
pub trait Continuous<T>
where
T: Real,
{
/// Probability density function
///
/// # Arguments
///
/// *`x`:
fn pdf(&self, x: T) -> T;
/// Cumulative distribution function
///
/// # Arguments
///
/// *`x`:
fn cdf(&self, x: T) -> T;
/// Quantile function, inverse cdf
fn quantile(&self, p: T) -> T;
/// Mean
fn mean(&self) -> T;
/// Variance
fn variance(&self) -> T;
/// Skewness is a measure of the asymmetry of the probability distribution
/// of a real-valued random variable about its mean
fn skewness(&self) -> T;
/// Median is the value separating the higher half from the lower half of a
/// probability distribution.
fn median(&self) -> T;
fn entropy(&self) -> T;
}
/// Discrete distribution
pub trait Discrete<T, A, B> {
/// Probability mass function
///
/// # Arguments
///
/// *`x`:
fn pmf(&self, x: A) -> T;
///Cumulative distribution function
///
/// # Arguments
///
/// * `x`:
fn cdf(&self, x: B) -> T;
/// Mean
fn mean(&self) -> T;
/// Variance
fn variance(&self) -> T;
}
|
All discrete distribution implements the Discrete trait
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
use crate::algebra::abstr::Real;
use std::iter;
pub trait Distribution<T>
where
T: Real,
{
fn random(&self) -> T;
fn random_sequence(&self, size: u32) -> Vec<T> {
let mut v: Vec<T> = Vec::new();
v.extend(iter::repeat_with(&|| self.random()).take(size as usize));
v
}
}
/// Continuous distribution
pub trait Continuous<T>
where
T: Real,
{
/// Probability density function
///
/// # Arguments
///
/// *`x`:
fn pdf(&self, x: T) -> T;
/// Cumulative distribution function
///
/// # Arguments
///
/// *`x`:
fn cdf(&self, x: T) -> T;
/// Quantile function, inverse cdf
fn quantile(&self, p: T) -> T;
/// Mean
fn mean(&self) -> T;
/// Variance
fn variance(&self) -> T;
/// Skewness is a measure of the asymmetry of the probability distribution
/// of a real-valued random variable about its mean
fn skewness(&self) -> T;
/// Median is the value separating the higher half from the lower half of a
/// probability distribution.
fn median(&self) -> T;
fn entropy(&self) -> T;
}
/// Discrete distribution
pub trait Discrete<T, A, B> {
/// Probability mass function
///
/// # Arguments
///
/// *`x`:
fn pmf(&self, x: A) -> T;
///Cumulative distribution function
///
/// # Arguments
///
/// * `x`:
fn cdf(&self, x: B) -> T;
/// Mean
fn mean(&self) -> T;
/// Variance
fn variance(&self) -> T;
}
|