Generate random numbers from a mixture distribution
古いコメントを表示
Hi, I would like to generate random numbers from a mixture distribution defined as:
pdf_mix = p*burrpdf(x,alpha,c,k) + (1-p)*wblpdf(x,a,b);
The aim is to compute a kstest2 between the observed data and the mixture distribution.
Is this possible? Can I get some help on this?
T PLOCOSTE
採用された回答
その他の回答 (3 件)
David Goodmanson
2019 年 8 月 3 日
編集済み: David Goodmanson
2019 年 8 月 3 日
Hi Thomas.
I presume you mean something like the following. A uniform random variable is used to create an index that picks from the first distribution with probability p, and from the second one with probability 1-p. Here I just arbitrarily made two different distributions from the standard normal distribution. You don't say if p = 2253/3849 in your case, but that's not necessary and p could be anything.
% normal distribution parameters
s1 = 1; mu1 = 1;
s2 = 2; mu2 = 5;
p = .2;
n = 1000;
R = zeros(1,n); % will be the final result
r = rand(1,n);
ind = r<p; % index for first distribution
np = sum(ind);
R( ind) = s1*randn(1,np ) + mu1; % np instances
R(~ind) = s2*randn(1,n-np) + mu2; % n-np instances
Jeff Miller
2019 年 8 月 3 日
1 投票
> With this formula I obtain a concatenation from 2 distribtutions but not a mixture.
Well, a mixture is just a concatenation from 2 distributions in random order. So you could just randomize the order of R and have your mixture.
As far as kstest2 goes, the order is not important, so you could in fact just use R and get the same kstest2 output.
But if your goal is to test whether the data come from a known distribution, you would really be better to treat that distribution as known and use a one-sample kstest. (I am not sure whether you can build the mixture distribution that you want as a MATLAB distribution object, however, so you might have to code up the kstest yourself if you want to go that route.)
cynthia thing
2021 年 1 月 24 日
0 投票
Hi Thomas, thank you for this post.
I am currently finding out about this too.
Hopefully you could help me if you are able to obtain.
Thank you
2 件のコメント
Thomas PLOCOSTE
2021 年 1 月 25 日
cynthia thing
2021 年 1 月 26 日
HI Thomas,
You were so helpful.
However I am wondering if I have a random data, which I would like to try to fit the dato into the function, will there be a generalized formula to it?(for example if I do not have a particular number of data that i know)
Thank you
カテゴリ
ヘルプ センター および File Exchange で Gaussian Mixture Distribution についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
