commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [math] Generate random data using the Inverse CDF Method?
Date Mon, 26 Oct 2009 23:50:07 GMT
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: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message