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 (NormalCDFFastAlgorithm.java) is fast but less precise then the other one (NormalCDFPreciseAlgorithm.java). 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. 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 NormalDistributionImpl.java. This is what really matters. 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 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 Double.NEGATIVE_INFINITY for p=0 and Double.POSITIVE_INFINITY for p=1. Any suggestions? Hope you'll find it useful Regards Piotr Kochanski, Warsaw University
NormalDistribution.zip
Description: Zip archive
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
