RandomVariable

Struct RandomVariable 

Source
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

Source

pub fn new(x: Vec<f64>, px: Vec<f64>) -> Self

Instantiates a new entry tracking outcomes and matching process weights.

Source

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);
Source

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)$$

Source

pub fn expectation_from_func<H>(&self, h: H) -> CDHResult<f64>
where H: Fn(f64) -> 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)$$

Source

pub fn expectation_from_set(&self, hx: &[f64]) -> CDHResult<f64>

Evaluates the functional expectation cross product against an isolated reference sequence slice.

Source

pub fn std_deviation(&self) -> CDHResult<f64>

Computes the standard deviation ($\sigma$) of the isolated distribution.

Source

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}]$$

Source

pub 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.

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.

Source

pub fn variance_operator<H>(&self, h: H) -> CDHResult<f64>
where H: Clone + Fn(f64) -> f64,

Calculates dispersion changes over custom functional projections while protecting closure scopes.

Trait Implementations§

Source§

impl Clone for RandomVariable

Source§

fn clone(&self) -> RandomVariable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RandomVariable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.