How small is Zero?
    3 views (last 30 days)
  
       Show older comments
    
    Ahmed Ramadan
 on 3 Mar 2023
  
    
    
    
    
    Answered: Walter Roberson
      
      
 on 3 Mar 2023
            I run some statistical analyses which result in p-values=0. Are they < the minimum positive value of a double precision (<2e-308), which is odd to me?
I am worried if another precision is used under the hood in the Statistics and Machine Learning Toolbox (e.g., corr).
0 Comments
Accepted Answer
  John D'Errico
      
      
 on 3 Mar 2023
        
      Edited: John D'Errico
      
      
 on 3 Mar 2023
  
      It is easy for that to happen. Of course, you don't actually tell us WHAT test you did. But this just means you have an event out in the tails. And it need not be even that far out.
For example, what is the probability of a standard Normally distributed number being as far out as -40?
format long g
Z = (-40:-35)';
[Z,normcdf(Z)]
So below 38 sigma, the probability just underflows. Actually, in context, -39*sigma really is a long way out. But outliers exist. It may mean your assumptions of normality may be in question.
But it is not at all impossible for a statistical test to yield an underflow as you have reported. You just need some data that justifies a result out in the tails.
4 Comments
  Walter Roberson
      
      
 on 3 Mar 2023
				
      Edited: Walter Roberson
      
      
 on 3 Mar 2023
  
			smallest_normal_number = realmin
smallest_representable_number = eps(smallest_normal_number)
IEEE 754 Double Precision has two ranges.
In the range that is used nearly all of the time, the representation is sign * 2^(exponent+ bias) * (2^53 + mantissa) . So for example, 1.0 exactly is stored as [0, -53+bias, 0] meaning (-1)^0*2^(-53) * (2^53 + 0) -- a mantissa of 0 and an exponent that cancels out the 2^53 giving 1. And 2.0 exactly is stored as [0, -52+bias, 0] meaning (-1)^0*2^(-52)*(2^53 + 0) canceling out to 2^(53-52) giving 2^1 == 2.0 . In this "normalized" range, in each case, the mantissa is an integer at most 2^53-1 and the representation is always such that doubling the number just increases the exponent by 1 without changing the mantissa.
The second range applies only to numbers that are less than 2^(-1022) . For such numbers, the representation is instead a fixed 2^(-1074) * mantissa where mantissa is at most 2^53-1 . In that range, doubling the number leaves the exponent fixed and requires doubling the mantissa itself. The increment between adjcent representable numbers in this "denormalized" range is fixed at 2^(-1074), whereas the increment numbers in the "normalized" range varies with floor(log2(abs()) of the number.
More Answers (1)
  Walter Roberson
      
      
 on 3 Mar 2023
        format long g
A = sym(floor(randn(5,2) * 16)) / 16
cord = corr(double(A))
cors = corr(A)
corsv = vpa(cors, 16)
corsd = double(cors)
That is, the corr() function happens to be able to run on symbolic numbers, and will provide exact results over a rather wide range -- 10^-10000 not being a problem for example. So you could test your "exact 0" 
0 Comments
See Also
Categories
				Find more on Analysis of Variance and Covariance in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





