How small is Zero?

조회 수: 1 (최근 30일)
Ahmed Ramadan
Ahmed Ramadan 2023년 3월 3일
답변: Walter Roberson 2023년 3월 3일
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).

채택된 답변

John D'Errico
John D'Errico 2023년 3월 3일
편집: John D'Errico 2023년 3월 3일
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)]
ans = 6×2
-40 0 -39 0 -38 2.88542835100396e-316 -37 5.72557122252514e-300 -36 4.18262406579739e-284 -35 1.12491070647255e-268
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
Walter Roberson
Walter Roberson 2023년 3월 3일
편집: Walter Roberson 2023년 3월 3일
smallest_normal_number = realmin
smallest_normal_number = 2.2251e-308
smallest_representable_number = eps(smallest_normal_number)
smallest_representable_number = 4.9000e-324
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.
Ahmed Ramadan
Ahmed Ramadan 2023년 3월 3일
Thank you, Les and Walter!
I do appreciate it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 3월 3일
format long g
A = sym(floor(randn(5,2) * 16)) / 16
A = 
cord = corr(double(A))
cord = 2×2
1 -0.864423766518445 -0.864423766518445 1
cors = corr(A)
cors = 
corsv = vpa(cors, 16)
corsv = 
corsd = double(cors)
corsd = 2×2
1 -0.864423766518445 -0.864423766518445 1
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"

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by