commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <>
Subject Re: [math] Contribution to o.a.c.math.distribution - NormalDistribution
Date Mon, 24 Nov 2003 21:04:35 GMT

I will add these in, I'd like to work to see us move to have a separate 
package for CDF's (I expect to place the Gamma and Beta functions there 
as well and to unify all these CDF style functions under one interface.

Basically we would have:




Piotr KochaƄski wrote:
> Hello!
> I would like to contribute to the o.a.c.math.distribution package
> the implementation of Normal distribution.
> I've implemented two algorithms for calculation of a cummulative
> distribution function - one of them ( 
> is fast but less precise then the other one
> (
> I think that having alternative in this case is useful since we
> have the standard (precise) algorithm available but when we
> need speed, we can use the other one - so the "java is slow people" 
> would not have an occasion to mess around.

I think we want to provide alternate implementations so people have 
multiple options available.

> In fact the fast algorithm
> is precise enough to be used in a majority of real-life
> applications (especially in social sciences).
> Code which calculates CDF is in the mentioned files, the code
> for the inverse CDF is in the This
> is what really matters.

Is it logical to consider having the inverse available in the Function 
interface and not the Distribution?

> I've organized the classes so that the precise
> algorithm is used as a default, but it is easy to switch to the other one:
> z = DistributionFactory.newInstance().createNormalDistribution(mean,
> standardDev);
> z.setCdfAlgorithm(new NormalCDFFastAlgorithm());
> You might not like the way I've implemented the alternative algorithms -
> this
> is just the Strategy Pattern, but one can achieve the same aim differently,
> maybe in a better way - 
> I wanted to stick as close as possible to the current implementation 
> of ContinousDistribution and be user friendly at the same time.

I think is acceptable, my interest is in seeing consistent interfaces 
for the functions and distributions, thats my only criticism

> I am not sure if the file names are the best one can think of too.
> I have adopted the convention that for standard deviation equal to zero
> cumulative distribution is always 0 and inverse CDF equals to the mean
> value.
> I am not quite convinced that for probability p=0 and p=1 inverse CDF
> should
> return NaN, maybe a better solution would be to return
> for p=0 and Double.POSITIVE_INFINITY for p=1. Any suggestions?

Well in the mathematical solution they would be infinite, wouldn't they? 
In such case this may be logical. I suspect if p<0 or p>1 they should be 

Looking good Piotr,

Mark Diggory
Software Developer
Harvard MIT Data Center

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

View raw message