[][src]Struct rv::dist::Crp

pub struct Crp { /* fields omitted */ }

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]

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]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,