commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <>
Subject Re: [math] Generate random data using the Inverse CDF Method?
Date Tue, 27 Oct 2009 13:03:27 GMT

Hate to put you to extra work here, but take a look here:

The idea is that you file an issue with JIRA and attach your patch there.
In order to encourage that, this mailing list strips attachments.

On Tue, Oct 27, 2009 at 4:08 AM, Mikkel Meyer Andersen <> wrote:

> I've attached a prototype diff-proposal where I've changed
> AbstractContinuousDistribution and AbstractIntegerDistribution, and
> implemented the nextExponential on the ExponentialDistribution as an
> example of overwriting the nextSample-method from the
> Abstract-distributions.
> Only AbstractContinuousDistribution and AbstractIntegerDistribution
> extends AbstractDistribution, and both AbstractIntegerDistribution and
> AbstractContinuousDistribution has an
> inverseCumulativeProbability-function. But in
> AbstractContinuousDistribution the inverse cdf returns a double, and
> at AbstractIntegerDistribution it - naturally - returns an integer.
> Therefor the nextSample is not put on AbstractDistribution, but on
> each extension with different return types.
> RandomGenerator as parameter instead of getting a RNG inside the
> nextSample, because one typically wants to use the same RNG because
> often several random samples are wanted. Another option is to have a
> RNG as a field in the class, but that would be more ugly and also
> result in several RNGs at runtime.
> I found an error as well. In RandomDataImpl, mean < 0 throws
> exception, whereas in the distribution implementation an exception is
> thrown if mean <= 0. RandomDataImpl is corrected to <= in because that
> is the correct definition.
> The function nextExponential couldn't - without further notice - be
> removed from RandomDataImpl, because nextPoisson and the ValueServer
> uses the function directly. So here is an issue. nextPoisson can
> create a ExponentialDistribution and sample from that. ValueServer
> could do the same, but what to you think about it?
> As mentioned, the diff is only a prototype hence no formal patch
> submitted. And no tests has been made neither. But should I report a
> bug or supply a separate patch on the small mean-problem in
> nextExponential in RandomDataImpl?
> Cheers, Mikkel.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Ted Dunning, CTO

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message