Someone please help me, I have probability mass function as follwing, How can generate 100 random values of j from this probability mass function?
古いコメントを表示

Note: λ>0 and 0≤α≤1/2 and 0≤P(X=j)≤1. (Take initial valus for λ, α and p(X=j) from thir domain as you like as example)
I want to generate randomly 100 numbers (values for j) with this probability mass function . But I really have no idea how and where to start.
Can somebody help me?
Thank you in advance
採用された回答
その他の回答 (2 件)
KSSV
2020 年 8 月 20 日
1 投票
- DEfine alpha and lambda values.
- DEfine j value.
- WRite your formula and substitute those values.
6 件のコメント
mohammed elmenshawy
2020 年 8 月 20 日
KSSV
2020 年 8 月 20 日
a = 0.3 ; ld = 0.5;
% f = 0.8 ;
f = zeros(1,100)
for j = 1:100
f(j) = ((1-a)^j-(-a)^j)*ld^j* exp(ld*a)/(factorial(j)*(exp(ld)-1)) ;
end
mohammed elmenshawy
2020 年 8 月 20 日
KSSV
2020 年 8 月 20 日
Firs few values are significant..rest are very small. Can you share the reference where you have this formula?
mohammed elmenshawy
2020 年 8 月 20 日
mohammed elmenshawy
2020 年 8 月 21 日
Bruno Luong
2020 年 8 月 21 日
編集済み: Bruno Luong
2020 年 8 月 21 日
alpha=0.01; lambda=0.99;
f=@(j) ((1-alpha).^j-(-alpha).^j).*lambda.^j*exp(lambda*alpha)./(factorial(j)*(exp(lambda)-1));
p=f(1:22); % f is practically 0 beyond 10
c=cumsum(p); c=c/c(end);
n = 100; % 1e6;
[~,j] = histc(rand(1,n),[0 c]);
カテゴリ
ヘルプ センター および File Exchange で Big Data Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!