[ 
https://issues.apache.org/jira/browse/MATH-359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12856335#action_12856335
 ] 

Christian Winter commented on MATH-359:
---------------------------------------

This issue is has the reason as 
[Math-282|https://issues.apache.org/jira/browse/MATH-282] and is resolved in 
Version 2.1. Thus it can be closed.

> Normal Distribution implementation gives false cumulative probabilities
> -----------------------------------------------------------------------
>
>                 Key: MATH-359
>                 URL: https://issues.apache.org/jira/browse/MATH-359
>             Project: Commons Math
>          Issue Type: Bug
>         Environment: Ubuntu Linux
>            Reporter: Joris
>            Priority: Minor
>
> Package: org.apache.commons.math.distribution
> Class: NormalDistributionImpl
> For a given mean and standard deviation, the class NormalDistributionImpl 
> implements a normal distribution. Per definition, the function 
> cumulativeProbability(double x) should return a value on the interval <0,1> 
> (0 and 1 excluded), for any real value of x. However, the following test case 
> shows that the method cumulativeProbability(double x) gives for some values 
> wrong results:
> NormalDistributionImpl ncdf=new 
> NormalDistributionImpl(0.06848215242239623,0.21287763557454142);
> try{
>       System.out.println("Test: 
> "+ncdf.cumulativeProbability(2.636630902183101));
> }catch(MathException e){ System.out.println("Exception has occurred: "+e);}
> Result:
> Test: 1.0000000000000064
> Only in the case where x=Double.POSITIVE_INFINITY,  
> cumulativeProbability(double x) should return 1. For all other values of x, 
> the result should be <1.
> The weird result from the above test case is quite likely caused by the data 
> type double. The 2 most straight forward ways to fix this behavior:
> 1. Use a more accurate data type
> 2. Build in checks which prevent bad results like:
> if(x==Double.POSITIVE_INFINITY)
>    return 1;
> else if(x==Double.NEGATIVE_INFINITY)
>    return 0;
> else if(result >=1)
>    return 0.9999999999999; //A constant value which is stored correctly by a 
> double
> else if(result <=0)
>    return 0.0000000000001;
> Nevertheless, I believe that this issue should be noted in the Javadoc of the 
> NormalDistributionImpl class. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to