[−][src]Struct rv::dist::Crp
Chinese Restaurant Process, a distribution over partitions.
Example
use::rv::prelude::*; let mut rng = rand::thread_rng(); let crp = Crp::new(1.0, 10).expect("Invalid parameters"); let partition = crp.draw(&mut rng); assert_eq!(partition.len(), 10);
Methods
impl Crp
[src]
pub fn set_alpha(&mut self, val: f64) -> &mut Self
[src]
Discount parameter
pub fn set_n(&mut self, val: usize) -> &mut Self
[src]
number of items in the partition
impl Crp
[src]
pub fn new(alpha: f64, n: usize) -> Result<Self>
[src]
Create an empty Crp
with parameter alpha
Arguments
- alpha: Discount parameter in (0, Infinity)
- n: the number of items in the partition
pub fn new_unchecked(alpha: f64, n: usize) -> Self
[src]
Create a new Crp without checking whether the parametes are valid.
pub fn alpha(&self) -> f64
[src]
Get the discount parameter, alpha
.
Example
let crp = Crp::new(1.0, 12).unwrap(); assert_eq!(crp.alpha(), 1.0);
pub fn n(&self) -> usize
[src]
Get the number of entries in the partition, n
.
Example
let crp = Crp::new(1.0, 12).unwrap(); assert_eq!(crp.n(), 12);
Trait Implementations
impl Rv<Partition> for Crp
[src]
fn ln_f(&self, x: &Partition) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> Partition
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
impl Support<Partition> for Crp
[src]
impl<'_> From<&'_ Crp> for String
[src]
impl Clone for Crp
[src]
impl Display for Crp
[src]
impl Debug for Crp
[src]
Auto Trait Implementations
impl Send for Crp
impl Sync for Crp
impl Unpin for Crp
impl UnwindSafe for Crp
impl RefUnwindSafe for Crp
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,