# how to work on uncertainty of matrix numbers

3 views (last 30 days)
Luca Freilino on 26 Jun 2019
Edited: John D'Errico on 26 Jun 2019
Hi everyone, I'm having a little problem with an algorithm I have to develop. I'm blocked at the first step since I don't know how to obtained the proper data. I have an input matrix, whose elements are different number, of different magnitude. e.g. I have [0.0058, 0.12, 745.2, 48572, etc...]. I'd like to save, for each coordinate, the uncertainity of the number. Referring to the previous example, it would save [0.0001, 0.01, 0.1, 1, etc]. I don't know if I succeeded in making me understood, soory for the troubles. Anyway, do you have any tips?
Best, Luca

John D'Errico on 26 Jun 2019
Edited: John D'Errico on 26 Jun 2019
This is not as easy as you think it should be, because numbers are not stored in MATLAB in decimal form. As such, what does MATLAB store for the number 0.0058? Is the uncertainty 0.0001? Or is it..
eps(0.0058)
ans =
8.673617379884035e-19
The problem is, a decimal fraction is NOT stored as a decimal fraction. It is stored in binary form. When you store the number 0.0058 in MATLAB, it stores it as:
sprintf('%.55f',0.0058)
ans =
'0.0057999999999999996003197111349436454474925994873046875'
So MATLAB does not know which of those digits was the last one you provided.
Worse, even your example has a problem, because even I cannot know what you would return for some numbers as the "uncertainty".
For example, you tell us that
48572
has an uncertainty of 1. So you might claim the last decimal digit is potentially in question. But suppose you gave a similar number, as this?
48570
Is the uncertainty there 10? Or is it 1? Zero IS a digit after all! The number 48570 is an integer, and your argument is that an integer has an "uncertainty" of 1. Just because the last digit of that integer is a zero does not mean the zero is not known quite accurately.
Next, suppose we decide that a number has an uncertainty of 1? Divide it by 10. Is the uncertainty now 0.1? But suppose we started with the number 48570? Is the uncertainty 1? If so, then 48570/10 has an uncertainty of 0.1. But 48570/10=4857. And thet number would arguably have an uncertainty of 1, at least by some flawed logic.
The point is, once a number has been input into MATLAB, you cannot decide what the "uncertainty" (as you would define it) of those numbers would have been, purely by looking at the number as it is stored in MATLAB.
All you can do is to use eps, which tells you the size of the least significant bit in that number, as it is stored as a double. But that is NOT what you asked for.

### Community Treasure Hunt

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

Start Hunting!

Translated by