Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Working with numbers smaller tha 10^-308

Asked by sadoune sadoune on 9 May 2013

Hi,

I would like to know if it is possible to use Matlab for very small numbers (smaller than 10^-308 ). It's very important for my application "statistical genetics". in this field, somes probabilities are smaller than 10^-500.

Thank you

4 Comments

Sean de Wolski on 9 May 2013

+1 @Robert's comment

sadoune sadoune on 9 May 2013

Hi Robert,

You can imagine a vector length 500, each case represent a probability, and the probability i would like to compute is the product of all this probabilities (independance).

John Doe on 9 May 2013

Ok, then I see where you get the number from, but if you are ending up with a probability that low, it is literally impossible for it to happen. Isn't OK to just let it be equal to 0?

I don't mean to be rude or condescending, I just don't get how it would make sense to keep working with numbers that low.

Anyhow, I hope someone can provide an answer for you, and good luck =)

sadoune sadoune

Products

No products are associated with this question.

2 Answers

Answer by Sean de Wolski on 9 May 2013
Edited by Sean de Wolski on 9 May 2013

You can do this using vpa() in the Symbolic Math Toolbox:

v = vpa('3.14159^-5000')

And for more info:

doc vpa

You could also use exact symbolic arithmetic:

sym('3.1415^-34334')

doc sym

3 Comments

sadoune sadoune on 10 May 2013

Thank you for your answer,

I tried vpa function with the following example:

 for i=1:400
tab(i)=0.1;
end

v = vpa(prod(tab))

and the result was v =0.0 :(

Sean de Wolski on 10 May 2013

That's because you're doing the computation as a double and then converting it to vpa(). Convert it to vpa before doing the computation:

for i=400:-1:1
  tab(i)=vpa(0.1);
end
v = (prod(tab))
sadoune sadoune on 10 May 2013

Thank you Wolski. it's OK now

Sean de Wolski
Answer by Peter Perkins on 11 May 2013

Quite often in statistics when one has very small probabilities, one works on the log scale. That's why one typically maximizes the LOG-likelihood, and not the likelihood.

0 Comments

Peter Perkins

Contact us