Large numbers multiplied by small numbers
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
James Wright
el 7 de Oct. de 2013
Editada: James Tursa
el 8 de Oct. de 2013
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
0 comentarios
Respuesta aceptada
James Tursa
el 8 de Oct. de 2013
Editada: James Tursa
el 8 de Oct. de 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
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!