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

Torsten
Torsten 2016년 4월 26일
And i ranges between which integer values ? And the Pi sum to 1 ?
Best wishes
Torsten.
Rafael  Pires
Rafael Pires 2016년 4월 26일
편집: Rafael Pires 2016년 4월 26일
i ranges between 1 and 100, Pi don't sum to 1. May you help me?
Torsten
Torsten 2016년 4월 26일
편집: Torsten 2016년 4월 26일
If the Pi don't sum to 1, you don't have a probability distribution.
Or maybe the Pi are defined as
Pi=1/(1+(i/31)^2.6)/sum_{j=1}^{j=100}1/(1+(j/31)^2.6)
?
In any case, you can use
Best wishes
Torsten.
Rafael  Pires
Rafael Pires 2016년 4월 26일
sorry, Pi sum to 1.
Torsten
Torsten 2016년 4월 26일
Use the MATLAB program from the file exchange above.
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

답변 (2개)

John BG
John BG 2016년 4월 26일
편집: John BG 2016년 4월 26일

0 개 추천

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

댓글 수: 1

Rafael  Pires
Rafael Pires 2016년 4월 26일
Thank you. That's ok, but how can I generate a random valou obeying this probability?

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2016년 4월 26일

0 개 추천

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.

질문:

2016년 4월 26일

답변:

2016년 4월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by