Alex Herbert created RNG-177:
--------------------------------

             Summary: Add stream methods to the sampler API
                 Key: RNG-177
                 URL: https://issues.apache.org/jira/browse/RNG-177
             Project: Commons RNG
          Issue Type: New Feature
          Components: sampling
    Affects Versions: 1.4
            Reporter: Alex Herbert
             Fix For: 1.5


Add default stream implementations to the sampler API interfaces
 * ContinuousSampler - DoubleStream
 * DiscreteSampler - IntStream
 * LongSampler - LongStream
 * ObjectSampler<T> - Stream<T>

e.g.
{code:java}
default DoubleStream samples() {
    return DoubleStream.generate(this::sample).sequential();
}  

default DoubleStream samples(long streamSize) {
    return samples().limit(streamSize);
}  {code}
This allows for example:
{code:java}
UniformRandomProvider rng = ...;
double[] data = ContinuousUniformSampler.of(rng, 1.23, 4.56)
                                        .samples(50)
                                        .toArray(); {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to