pub struct RandomVariable {
pub variable: Vec<f64>,
pub probability: Vec<f64>,
}Expand description
Represents a univariate discrete Random Variable containing mapped outcomes and matching probability mass profiles.
§Struct Elements
variable: Contiguous storage tracking distinct numeric real outcomes ($X$).probability: Matching distribution array tracking distinct weights or probability mass parameters ($P(X)$).
Fields§
§variable: Vec<f64>§probability: Vec<f64>Implementations§
Source§impl RandomVariable
impl RandomVariable
Sourcepub fn new(x: Vec<f64>, px: Vec<f64>) -> Self
pub fn new(x: Vec<f64>, px: Vec<f64>) -> Self
Instantiates a new entry tracking outcomes and matching process weights.
Sourcepub fn mean(&self) -> CDHResult<f64>
pub fn mean(&self) -> CDHResult<f64>
Computes the true expectation parameter mean ($E[X]$) of the random process.
$$E[X] = \sum x_i p(x_i)$$
§Example
let rv = RandomVariable::new(vec![1.0, 2.0], vec![0.5, 0.5]);
assert_eq!(rv.mean().unwrap(), 1.5);Sourcepub fn variance(&self) -> CDHResult<f64>
pub fn variance(&self) -> CDHResult<f64>
Computes the exact variance ($\text{Var}(X)$) using structural deviations to counter float degradation noise.
$$\text{Var}(X) = E[(X - \mu)^2] = \sum (x_i - \mu)^2 p(x_i)$$
Sourcepub fn expectation_from_func<H>(&self, h: H) -> CDHResult<f64>
pub fn expectation_from_func<H>(&self, h: H) -> CDHResult<f64>
Transforms elements via an arbitrary closure parameter and sums the targeted transformation grid weights.
$$E[h(X)] = \sum h(x_i) p(x_i)$$
Sourcepub fn expectation_from_set(&self, hx: &[f64]) -> CDHResult<f64>
pub fn expectation_from_set(&self, hx: &[f64]) -> CDHResult<f64>
Evaluates the functional expectation cross product against an isolated reference sequence slice.
Sourcepub fn std_deviation(&self) -> CDHResult<f64>
pub fn std_deviation(&self) -> CDHResult<f64>
Computes the standard deviation ($\sigma$) of the isolated distribution.
Sourcepub fn moment_generating_func(&self, t: f64) -> CDHResult<f64>
pub fn moment_generating_func(&self, t: f64) -> CDHResult<f64>
Generates the Moment Generating Function evaluation value ($M_X(t)$) using precise hardware-level scaling exponents.
$$M_X(t) = E[e^{tX}]$$
Sourcepub fn characteristic_func(&self, t: f64) -> CDHResult<f64>
👎Deprecated since 0.1.0: Returns Err. f64 cannot represent complex numbers required for E[e^(itX)]. Will be implemented when complex number support is added.
pub fn characteristic_func(&self, t: f64) -> CDHResult<f64>
Deprecated method indicating complex real-space value tracking limits.
§Errors
Always returns an Err variant because complex number tracks require imaginary extensions not native to f64.
Trait Implementations§
Source§impl Clone for RandomVariable
impl Clone for RandomVariable
Source§fn clone(&self) -> RandomVariable
fn clone(&self) -> RandomVariable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more