Skip to content

Multi-dimensional distributions #16

@dhardy

Description

@dhardy

#14 argues the importance of a variable-length input Dirichlet distribution. rust-random/rand#1478 proposes a Multinomial distribution.

It is also questionable whether the existing Distribution trait is appropriate for these; it may be preferable to use a distinct trait like:

pub trait MultiDistribution<F> {
    fn sample<R: Rng + ?Sized>(&mut self, rng: &mut R, output: &mut [F]);
}

Although:

  • The above does not support error checking of the length of output, aside from panic. This may be the most appropriate option anyway, though I would expect at minimum that implementations do assert the length of output is exactly as expected.
  • There is probably no reason to add this trait over simply adding pub fn sample methods to the distribution types.

Questions:

  • Should we start a new rand_multi crate? Or maybe rand_distr::multi module?
  • Should we add a new MultiDistribution trait? Or simply use methods on the distributions without a trait?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions