how to cope with big numbers out of the capability of matlab
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
xueqi
el 22 de Mayo de 2014
Respondida: Star Strider
el 23 de Mayo de 2014
Dear Fellows,
I would like to calculate the probability mass function for the generalize binomial distribution. Basically I just need to add a extra parameter in the usual pmf function of binomial distribution. I attach the code here.
if true
% n=100;
p=0.5;
x=1:100;
nthetas=1.6 %the value of nthetas is starting from 1
C=x.*(100-x);
pmf_=binopdf(x,100,0.5).*(nthetas.^C); %add the dispense parameter to a usual binomial distribution pmf
z=sum(pmf_); %normalized constant
pmf=pmf_/z;
end
There is no problem when theta is equal to 1.2. But when it gets bigger, for example 1.6 as in the code. The probability gets too big to calculate and ends up as Inf. Do you know how to deal with this problem?
Thanks!
0 comentarios
Respuesta aceptada
Star Strider
el 23 de Mayo de 2014
I suggest writing your own function, but using logarithms to do the calculations. That may not be as precise and you may not be able to take the antilogs in the end (they would likely be Inf). I don’t know how far you would get with logarithmic calculations, but converting the results from natural to base-10 logs in the end will give you the ability to get farther than you are now.
There could be something inherent in MATLAB’s calculations that would prohibit this approach, but it’s worth experimenting to find out.
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!