commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <>
Subject [jira] [Commented] (MATH-764) New sample() API should accept RandomGenerator as parameter
Date Sun, 27 May 2012 06:46:23 GMT


Phil Steitz commented on MATH-764:

A aimple way to provide the requested functionality without breaking compatibility might be
to add setRandomGenerator methods to AbstractXxxDistribution.  This violates immutability,
but the reseedRandomGenerator methods currently provided arguably do this already with essentially
the same practical consequences.  To implement this, randomData would have to be made non-final
and the setter would have to recreate it using the supplied generator.

If this is distasteful, I would suggest, as Gilles mentions above, just using RandomDataImpl
directly, which provides direct support for sampling with configurable RandomGenerator.  The
setup in the patch looks like a long way around the barn to just get back to what is there
already in RandomDataImpl.
> New sample() API should accept RandomGenerator as parameter
> -----------------------------------------------------------
>                 Key: MATH-764
>                 URL:
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Alex Bertram
>         Attachments: sampler-refactor.diff
>   Original Estimate: 48h
>  Remaining Estimate: 48h
> This may come to late as I know the 3.0 release is nearing completion, but I had some
concerns about the new sample() method on the math3 RealDistribution interface. 
> Specifically, there doesn't seem to be a way to supply a random generator to the sampler.
Perhaps it would be better to have a factory method on the RealDistribution interface that
accepted a RandomGenerator and returns an instance of some new interface, Sampler, which contains
the sample() methods. 
> That is:
> interface RealDistribution {
>     Sampler createSampler(RandomGenerator generator);
>     Sample createSampler(); // uses default RandomGenerator
> }
> interface Sampler {
>     double sample();
>     double[] sample(int sampleSize);
> }

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message