commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject [math] Re: NormalDistribution
Date Sat, 20 Feb 2010 15:11:24 GMT
kalpa rajadurai wrote:
> Hi Team,
> 
> We are working on a small project in designing a web based statistical
> calculator, supporting certain distribution functions.
> 
> we used  method *cummulativeProbability(double x)* of *class
> NormalDistributionImpl* for implementing Normal distribution function.
> 
> We tried to cross check Apache API's result with that of OpenOffice Calc and
> Excel's result. In most of the cases, the results matched with each other.
> But in certain rare cases, the cumulativeProbability() method returned by
> slightly different result when compared to the result returned by NORMDIST()
> function of openoffice calc and Excel.
> 
> Here goes the illustration of the case where we found the mismatch in
> results:
> 
> *Using Apache's API:*
> NormalDistribution normDist = new NormalDistributionImpl(40,1.5)
> ;
> try{
> System.out.println("cummulative probability::
> "+normDist.cumulativeProbability(0.908789));
> }
> catch(MathException e){
> e.printStackTrace();
> }
> 
> *Result:*
> cummulative probability:: *-8.104628079763643E-15*
> 
> *Using openoffice calc:*
> Same input values given in openoffice calc using the formula:
> *=NORMDIST(0.908789;40;1.5;1)*
> 
> *Result:*
> *0.0*
> 
> *Using Microsoft Excel:*
> Same input values given in excel using the formula:
> *=NORMDIST(0.908789;40;1.5;1)*
> 
> *Result:*
> *5.0738E-150*
> 
> *Different results:*
> Apache  -8.104628079763643E-15
> Openoffice 0.0
> Excel 5.0738E-150
> 
> We wish to know the following things,
> 1.) What is the reason for this variation in results?

The difference is due to different numeric algorithms used to
approximate the cumulative probabilities - in particular how extreme
values are handled.  The probability in the example is very close to
zero - all three agree on that.

> 2.) Which result is more accurate?

Excel is likely the best answer; though the only confirmation that I
can give of that is that R gives the same answer and the correct
answer is certainly positive.  The worst answer is the one reported
by commons-math.  The value should not be negative.  This is likely
related to an open bug (MATH-301).  Thank you for reporting this.

> 3.) Is there any possibility to get the same results as Open Office or Excel
> for this case, using Apache's API?

Commons Math 2.1 will correct the bug mentioned above, so we will
return either 0 or a positive value for this and other extreme tail
probabilities.

Thanks again for pointing out the discrepancy.

Phil

> 
> Hope to receive reply from your team at the earliest as possible.
> Thanks in Advance
> 


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


Mime
View raw message