Skip to content

gen_iter() for distributions? #58

@JP-Ellis

Description

@JP-Ellis

The Rng trait has the gen_iter() function which creates an iterator producing an infinite numbers of random numbers. It is then easy to manipulate the the iterator and generate vectors of random numbers.

Is there a reason why the various distributions do not implement this? In my particular case, I am needing to create vectors of numbers distributed normally and there is no easy way of doing that. One can't use vec![normal.ind_sample(rng); len]; because it evaluates the function once and then clones the result.

I am quite happy to implement this in this crate (if people are interested). I was thinking of maybe adding gen_iter<R: Rng>(&mut self, rng: &mut R) and gen_ind_iter<R: Rng>(&mut self, rng: &mut R) under Sample and IndependentSample respectively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyParticipation: easy jobF-new-intFunctionality: new, within Rand

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions