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

Luc Maisonobe commented on MATH-1185:
-------------------------------------

The problem is not the global magnitude. Values of the order of magnitude of 
10^-308 can be represented, and values of the order of 10^+308 can also be 
represented. The problem is how you compute the value.

All normal numbers have about 15 significant digits. This means that when you 
are speaking of 10^-295, the most significat digit is 10^-295 and the least 
significant digit if 15 orders of magnitude lowers, hence 10^-308.

Here, you start from something of the order of magnitude of 1.0, so the most 
significant digit is 10^0 and the least significant digit is 10^-15. When you 
do the subtraction, you cannot recover digits smaller that 10^-15 because they 
were not in the number you started from.

I do not think R uses higher precision. I think they do not use 1 - x here, but 
compute the value using another direct algorithm/

This is exactly the same problem as computing exp(t) -1 for small t. If you do 
it the obvious way, by first computing the exponential function and then 
subtracting 1, you have very bad results. This is the reason why all 
mathemetical libraries provide a function expm1(t) which does not use the 
obvious way and therefore avoids the subtraction, allowing extremely high 
accuracy here.

I don't know if for the expression you need such a dedicated algorithm exists, 
but for sure if you need this level of accuracy, don't use a subtraction with 
1. 

> Tail probability drops to zero beyond 10e-17 ?
> ----------------------------------------------
>
>                 Key: MATH-1185
>                 URL: https://issues.apache.org/jira/browse/MATH-1185
>             Project: Commons Math
>          Issue Type: Wish
>    Affects Versions: 3.3, 3.4
>            Reporter: Sriram Natarajan
>            Priority: Minor
>
> This could be a  simple question, In which case I can expect a clarification. 
> If this is the wrong place to post such a question, let me know.
> OS: Windows 8.1, Java 1.8.0_25
> ChiSquaredDistribution chisq = new ChiSquaredDistribution(23)
> 1.0 - chisq.cumulativeProbability(130) is  1.1102230246251565E-16
> 1.0 - chisq.cumulativeProbability(131) is  0.0  
> Am pretty sure it is not a formatting issue.  Is there a reason why the tail 
> drops to zero at this point?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to