pub struct DenseDist<T> { /* private fields */ }Expand description
Implementations§
Trait Implementations§
Source§impl<T> AsRand<T> for DenseDist<T>where
for<'b> T: Num + FromPrimitive + PartialOrd + Clone + Weight + SampleUniform + MulAssign<&'b T> + SubAssign<&'b T> + AddAssign<&'b T>,
impl<T> AsRand<T> for DenseDist<T>where
for<'b> T: Num + FromPrimitive + PartialOrd + Clone + Weight + SampleUniform + MulAssign<&'b T> + SubAssign<&'b T> + AddAssign<&'b T>,
Source§fn to_rand_distribution(&self) -> impl Distribution<isize>
fn to_rand_distribution(&self) -> impl Distribution<isize>
Convert to a
Distribution. Useful for sampling.Source§impl<'de, T> Deserialize<'de> for DenseDist<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for DenseDist<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Dist<T> for DenseDist<T>where
for<'b> T: Num + FromPrimitive + PartialOrd + Clone + MulAssign<&'b T> + SubAssign<&'b T> + AddAssign<&'b T>,
impl<T> Dist<T> for DenseDist<T>where
for<'b> T: Num + FromPrimitive + PartialOrd + Clone + MulAssign<&'b T> + SubAssign<&'b T> + AddAssign<&'b T>,
Source§fn chance(&self, n: isize) -> Option<&T>
fn chance(&self, n: isize) -> Option<&T>
The chance that n will be sampled from the distribution. Returns
None if outside the distribution’s support.
use diceystats::{
dices::DiceFormula,
dist::{DenseDist, Dist},
};
let expr: DiceFormula = "d10".parse().unwrap();
let dist: DenseDist<f64> = expr.dist();
let p = dist.chance(3).unwrap_or(&0.0);
assert_eq!(1.0 / 10.0, *p);Source§fn distance(&self, other: &DenseDist<T>) -> T
fn distance(&self, other: &DenseDist<T>) -> T
Distance between two distributions, measured by total elementwise difference of probabilities.
use diceystats::{
dices::DiceFormula,
dist::{DenseDist, Dist},
};
use num::BigRational;
let expr1: DenseDist<_> = "d4xd3".parse::<DiceFormula>().unwrap().dist();
let expr2: DenseDist<_> = "d4+d6".parse::<DiceFormula>().unwrap().dist();
let d: BigRational = expr1.distance(&expr2);
assert_eq!(d.to_string(), "25/54")Source§fn distance_max(&self, other: &DenseDist<T>) -> T
fn distance_max(&self, other: &DenseDist<T>) -> T
Distance between two distributions, measured by maximum elementwise difference of probabilities
use diceystats::{
dices::DiceFormula,
dist::{DenseDist, Dist},
};
use num::BigRational;
let expr1: DenseDist<_> = "d4xd3".parse::<DiceFormula>().unwrap().dist();
let expr2: DenseDist<_> = "d4+d6".parse::<DiceFormula>().unwrap().dist();
let d: BigRational = expr1.distance_max(&expr2);
assert_eq!(d.to_string(), "1/12");fn evaluator() -> impl Evaluator<Self>
Source§fn new_constant(n: isize) -> Self
fn new_constant(n: isize) -> Self
New constant distribution,
n has a 100% chance of occuring.Source§fn iter_enumerate<'a>(&'a self) -> impl Iterator<Item = (isize, &'a T)>where
T: 'a,
fn iter_enumerate<'a>(&'a self) -> impl Iterator<Item = (isize, &'a T)>where
T: 'a,
Iteratete through the distribution’s support, in order.
fn min_value(&self) -> isize
fn max_value(&self) -> isize
Source§fn new_uniform(min: isize, max: isize) -> Self
fn new_uniform(min: isize, max: isize) -> Self
New uniform distribution from
min to, and including, max.Source§impl<T: Ord> Ord for DenseDist<T>
impl<T: Ord> Ord for DenseDist<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for DenseDist<T>
impl<T: PartialOrd> PartialOrd for DenseDist<T>
impl<T: Eq> Eq for DenseDist<T>
impl<T> StructuralPartialEq for DenseDist<T>
Auto Trait Implementations§
impl<T> Freeze for DenseDist<T>
impl<T> RefUnwindSafe for DenseDist<T>where
T: RefUnwindSafe,
impl<T> Send for DenseDist<T>where
T: Send,
impl<T> Sync for DenseDist<T>where
T: Sync,
impl<T> Unpin for DenseDist<T>where
T: Unpin,
impl<T> UnwindSafe for DenseDist<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more