Retaining precision after subtraction

  • Follow


I've a simple question:

I have a script that calculates a p-value, which is often a tiny number (i.e. 1e-80).  I need the script to return the 1-p value but retain the precision.  When I try to do this, matlab always returns 1 for p-values below 1e-15.  Can anyone tell me how to retain the precision of the calculation ?

Thanks in advance
0
Reply kevbrick 4/27/2010 8:52:04 PM

"kevbrick Brick" <kevbric.k+spam@gmail.com> wrote in message <hr7ipk$kbg$1@fred.mathworks.com>...
> I've a simple question:
> 
> I have a script that calculates a p-value, which is often a tiny number (i.e. 1e-80).  I need the script to return the 1-p value but retain the precision.  When I try to do this, matlab always returns 1 for p-values below 1e-15.  Can anyone tell me how to retain the precision of the calculation ?

help EPS

After you'll know why what you ask is not possible, unless you perform symbolic calculation.

Bruno
0
Reply Bruno 4/27/2010 9:29:05 PM


"kevbrick Brick" <kevbric.k+spam@gmail.com> wrote in message <hr7ipk$kbg$1@fred.mathworks.com>...
> I've a simple question:
> 
> I have a script that calculates a p-value, which is often a tiny number (i.e. 1e-80).  I need the script to return the 1-p value but retain the precision.  When I try to do this, matlab always returns 1 for p-values below 1e-15.  Can anyone tell me how to retain the precision of the calculation ?
> 
> Thanks in advance
-----------
  It is inherent in double precision floating point numbers that subtracting a number less than 2^(-54) (which is about 5.55e-17) from 1 will not change the 1.  Even with substantially larger numbers there would be a heavy loss of precision in such a subtraction.  You cannot have it otherwise if you use 'double' numbers.  You will have to make some alteration in your script to return just the p-value without subtracting it from 1 and alter your program that receives it accordingly.

  The only alternative would be to deal with symbolic quantities that are capable of much higher accuracy perhaps using the 'vpa' facility.

Roger Stafford  
0
Reply Roger 4/27/2010 9:31:04 PM

kevbrick Brick wrote:
> I've a simple question:
> 
> I have a script that calculates a p-value, which is often a tiny number 
> (i.e. 1e-80).  I need the script to return the 1-p value but retain the 
> precision.  When I try to do this, matlab always returns 1 for p-values 
> below 1e-15.  Can anyone tell me how to retain the precision of the 
> calculation ?

Besides the other response, I'd suspect that a probability estimate of 
1E-80 is probably meaningless, anyway.

But, you could in the case in point generate the text result pretty 
easily since it's the number of 9's of the exponent followed by the 
remainder from 1.0 of p*1E(exp).  (Not that I think printing that out 
will do anybody any good... :) )

--
0
Reply dpb 4/27/2010 11:24:18 PM

3 Replies
254 Views

(page loaded in 0.04 seconds)

Similiar Articles:







7/14/2012 5:50:50 PM


Reply: