commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikkel Meyer Andersen <>
Subject Re: [math] Generate random data using the Inverse CDF Method?
Date Tue, 27 Oct 2009 00:06:55 GMT
Hi Phil.

Yes, I have seen RandomDataImpl and the next{Int, Poisson, ...}, but
as you mention not that many distributions are supported. What I
talked about is kind of the nextInversionDeviate-idea.

I must admit, that I find it a bit weird that the distributions are
separated from the random generation, i.e. the next{Int, ...}-method.
Ideally, when you have an instance of a distribution with the
parameters already specified, it would be nice to just get a sample
from the distribution just like when you find probability mass or what

Yes, ContinuousDistribution have it, but DiscretDistributions doesn't?
And discrete have inverse cdfs as well.

Cheers, Mikkel.

2009/10/27 Phil Steitz <>:
> Mikkel Meyer Andersen wrote:
>> Dear community.
>> I've just started using the Apache Commons Math library. In regards to
>> generating random data from probability distributions, the library
>> doesn't support generating random data using the inverse cdf method
>> although a lot of the distributions gives the possibility to calculate
>> the inverse cdf.
> Have you looked at the RandomData interface and RandomDataImpl
> class?  This class provides methods for generating random deviates
> from multiple distributions, in some cases using inverse cdfs (see
> e.g. RandomDataImpl#nextExponential().
>> Are there any particular good reason for this?
>> If not, I would create a public interface
>> DistributionWithInverseCumulativeProbability (who has a better name?)
>> with the method inverseCumulativeProbability (right now it's on
>> ContinuousDistribution and some other subclasses and don't seem to be
>> gathered in an interface) and all the distributions with the
>> inverseCumulativeProbability-method should implement this interface.
> I am not following you here. What exactly is the difference between
> DistributionWithInverseCumulativeProbability and
> ContinuousDistribution?  ContinuousDistribution extends Distribution
> with the inverseCumulativeProbability method you are describing.
>> With this small change, a new class called
>> RandomDistributionWithInverseCumulativeProbability (again, who has a
>> better name?) could simply use the uniform generator and a class
>> implementing DistributionWithInverseCumulativeProbability to generate
>> random data from that distribution.
> This is essentially what RandomDataImpl does for the distributions
> that it supports. Support for more distributions would be a welcome
> addition.  I guess along the lines of what you are talking about
> above, it might make sense to add a single generic
> nextInversionDeviate method paramaterized by ContinuousDistribution.
> The implementation of this would use a uniform generator and
> inversion to generate deviates.  That would be simpler than creating
> separate classes for each distribution or adding random data
> generation to the distributions themselves.  It would also be more
> consistent with the current organization of the code, which locates
> random data generation in the random package.
> Phil
>> What do you think about that idea? I look forward to comments,
>> suggestions, and preferably, better names :-).
>> Cheers, Mikkel Meyer Andersen.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message