How to use this probability distribution?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have this probability distribution: Pi=1/(1+(i/31)^2,6) (Pi is the probability of i happens). But, how can I use this probability (Pi) for generate a random value? Which function I should use?
5 comentarios
Torsten
el 26 de Abr. de 2016
Use the MATLAB program from the file exchange above.
Best wishes
Torsten.
Respuestas (2)
John BG
el 26 de Abr. de 2016
Editada: John BG
el 26 de Abr. de 2016
1.- it's good practice to avoid giving names to variables that are reserved for constants, like pi, so let me call the probability simply p, ok?
2.- when trying your function:
i=[0:10];p=1/(1+(i/31)^2,6)
errors happen,
so again let me modify the function you want to turn into a probability function, as follows:
i=[0:10];p=1./(1+(i/31).^2.6)
3.- with
i=[1:100]
format long
sum(p)
=
36.661222264870894
so a straight forward way to turn this into a probability density function is to divide all possibilities by
i=[1:100];
p=1./(1+(i/31).^2.6);
P0=sum(p);
p1=1/P0*(1./(1+(i/31).^2.6));
now
sum(p1)
=
0.999999999999999
sum(p1) should be exactly 1.
4.- Because the exponent of i is larger than 2, the sum of the series converges as i gets away heading to +Inf.
One way to include all possible positive values of i [1,Inf] is
syms k
f=1./(1+(k/31).^2.6)
int(f,k)
=
(155*log((244140625*31^(4/5)*k^(1/5))/31 + 244140625))/13 + (155*exp((pi*2i)/13)*log(1650390625*exp((pi*3i)/13) - (1650390625*31^(4/5)*k^(1/5))/31))/13 - (155*exp((pi*5i)/13)*log(1650390625*exp((pi*1i)/13) - (1650390625*31^(4/5)*k^(1/5))/31))/13 - (155*exp((pi*1i)/13)*log(1650390625*exp((pi*8i)/13) + (1650390625*31^(4/5)*k^(1/5))/31))/13 + (155*exp((pi*4i)/13)*log(1650390625*exp((pi*6i)/13) + (1650390625*31^(4/5)*k^(1/5))/31))/13 - (155*exp((pi*7i)/13)*log(1650390625*exp((pi*4i)/13) + (1650390625*31^(4/5)*k^(1/5))/31))/13 + (155*exp((pi*10i)/13)*log(1650390625*exp((pi*2i)/13) + (1650390625*31^(4/5)*k^(1/5))/31))/13 - (155*exp((pi*3i)/13)*log(1650390625*exp((pi*11i)/13) - (1650390625*31^(4/5)*k^(1/5))/31))/13 + (155*exp((pi*6i)/13)*log(1650390625*exp((pi*9i)/13) - (1650390625*31^(4/5)*k^(1/5))/31))/13 - (155*exp((pi*9i)/13)*log(1650390625*exp((pi*7i)/13) - (1650390625*31^(4/5)*k^(1/5))/31))/13 + (155*exp((pi*12i)/13)*log(1650390625*exp((pi*5i)/13) - (1650390625*31^(4/5)*k^(1/5))/31))/13 + (155*exp((pi*8i)/13)*log(1650390625*exp((pi*12i)/13) + (1650390625*31^(4/5)*k^(1/5))/31))/13 - (155*exp((pi*11i)/13)*log(1650390625*exp((pi*10i)/13) + (1650390625*31^(4/5)*k^(1/5))/31))/13
your probability density function has as primitive, so let's integrate:
double(int(1/((k/31)^(13/5) + 1),1,Inf))
=
39.060785674272687 - 0.000000000000000i
5.- one candidate to the probability density function you are after would be
P0=39.060785674272687
p=1/P0;1./(1+(i/31).^2.6)
for any positive integer >0, the range being
[1,Inf]
If you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John
Image Analyst
el 26 de Abr. de 2016
You need to use inverse transform sampling. https://en.wikipedia.org/wiki/Inverse_transform_sampling
I've attached an example where I use that method for the Rayleigh distribution. If you don't know the analytical formula for the CDF, you could always construct the digital PDF and then use cumsum() to get the CDF.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!