commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikkel Meyer Andersen <m...@mikl.dk>
Subject Re: [math] Generate random data using the Inverse CDF Method?
Date Mon, 26 Oct 2009 22:58:18 GMT
Hi Ted.

Thanks or your answer.

I like the idea about an abstract class named
DistributionWithInverseCumulativeProbability. But I have to look
closer where in the chain it should be. Because both
AbstractIntegerDistribution and AbstractContinuousDistribution have
the inverse cd method. And both extends AbstractDistribution, but
AbstractDistribution doesn't have an inverse cdf. So the best might be
to put an inverse cd method at AbstractDistribution, and throw an
exception, because AbstractIntegerDistribution and
AbstractContinuousDistribution implements it. How does that sound?

Cheers, Mikkel.

2009/10/26 Ted Dunning <ted.dunning@gmail.com>:
> If you define this new interface, can't you just put the correct
> implementation of the generator into some abstract class somewhere and make
> sure that all of the distributions implement this.  That implementation can
> check if this extends DistributionWithInverseCumulativeProbability.  If it
> does, then generating a sample is easy.  If not, throwing
> UnImplementedOperation would be in order.
>
> For that matter, would it be better to just insert an abstract class named
> DistributionWithInverseCumulativeProbability somewhere in the inheritance
> chain?  Do we need the interface at all?
>
> On Mon, Oct 26, 2009 at 3:09 PM, Mikkel Meyer Andersen <mikl@mikl.dk> 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.
>>
>> 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.
>>
>> 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.
>>
>> 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
>>
>>
>
>
> --
> Ted Dunning, CTO
> DeepDyve
>

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


Mime
View raw message