You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2022/05/04 11:15:00 UTC
[jira] [Created] (RNG-177) Add stream methods to the sampler API
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)