MATLAB Answers

how to work on uncertainty of matrix numbers

3 views (last 30 days)
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

Accepted Answer

John D'Errico
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..
ans =
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:
ans =
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
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?
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.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by