Large numbers multiplied by small numbers

2 ビュー (過去 30 日間)
James Wright
James Wright 2013 年 10 月 7 日
編集済み: James Tursa 2013 年 10 月 8 日
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

採用された回答

James Tursa
James Tursa 2013 年 10 月 8 日
編集済み: James Tursa 2013 年 10 月 8 日
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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by