Large numbers multiplied by small numbers

2 views (last 30 days)
Hi, I'm trying to compute at multinomial distribution as described here but my numbers are very large, so for example I have
(factorial(10201))/(factorial(1779)*factorial(8048)*factorial(374))*(0.1754515^1779)*(0.794171^8048)*(0.030847^374)
I could probably get round the large factorials without much difficulty by cancelling before computing, but I'm stuck with the very small multipliers which always evaluate to zero. I've considered splitting the indices up, so they can be multiplied separately. However as this case demonstrates, I still run into problems with large primes. i.e.
0.1754515^1779 = (0.1754515^593)^3
but 0.1754515^593 still evaluates to zero and 593 is prime. Is there any way to do this?
Thanks,
James

Accepted Answer

James Tursa
James Tursa on 8 Oct 2013
Edited: James Tursa on 8 Oct 2013
Some options:
1) Use the symbolic toolbox
2) Work with the log of the expression
If I have done the math correctly,
exp(gammaln(10201+1) + 1779*log(0.1754515) + 8084*log(0.794171) + 374*log(0.030847) - gammaln(1779+1) - gammaln(8084+1) - gammaln(374+1))
= 6.280311697766785e-149

More Answers (0)

Community Treasure Hunt

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

Start Hunting!