How small is Zero?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
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)]
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
2023년 3월 3일
편집: Walter Roberson
2023년 3월 3일
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.
추가 답변 (1개)
Walter Roberson
2023년 3월 3일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Hypothesis Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!