You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2021/07/22 18:19:00 UTC
[jira] [Commented] (STATISTICS-33) Remove the utility function to
create an array of samples from a Sampler
[ https://issues.apache.org/jira/browse/STATISTICS-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17385704#comment-17385704 ]
Gilles Sadowski commented on STATISTICS-33:
-------------------------------------------
bq. I suggest moving them to TestUtils.
Why not remove them altogether?
> Remove the utility function to create an array of samples from a Sampler
> ------------------------------------------------------------------------
>
> Key: STATISTICS-33
> URL: https://issues.apache.org/jira/browse/STATISTICS-33
> Project: Apache Commons Statistics
> Issue Type: Improvement
> Components: distribution
> Affects Versions: 1.0
> Reporter: Alex Herbert
> Priority: Trivial
>
> The following utility methods can be removed:
> {code:java}
> abstract class AbstractDiscreteDistribution {
> public static int[] sample(int n,
> DiscreteDistribution.Sampler sampler)
> }
> abstract class AbstractContinuousDistribution {
> public static double[] sample(int n,
> ContinuousDistribution.Sampler sampler)
> }
> {code}
> They exists as utility methods in a package-private abstract class (thus the public modifier is confusing). I suggest moving them to TestUtils. They can be replicated in code by using a stream:
> {code:java}
> ContinuousDistribution d = ...;
> UniformRandomProvider rng = ...;
> int n = 1000;
> double[] samples = DoubleStream.stream(d.createSampler(rng)::sample)
> .limit(n)
> .toArray();
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)