How can i select random sample from mixture of two normal distributions in MATLAB ?

조회 수: 1 (최근 30일)
Hi everyone Could you please let me know how can i select random sample from contaminated normal distribution (i.e., mixture of two normal distributions) in MATLAB? .Suppose i need a sample of 100 values from mixture normal distributions such that 5% values are from Normal distribution with mean zero and variance 25 and 95% values are from normal with mean zero and variance 1. In mathematical terms i can write my problem as:
5% from N(0,25)+95% from N(0,1) This is mixture random sample of two normal distributions.

채택된 답변

Roger Stafford
Roger Stafford 2016년 5월 1일
r = rand(100,1)>=.05;
R1 = normrnd(0,sqrt(25),100,1);
R2 = normrnd(0,sqrt(1),100,1);
S = (1-r).*R1+r.*R2;
S contains your 100 samples.
This assumes that your two normal distributions are statistically independent.
  댓글 수: 4
zahid
zahid 2016년 5월 6일
Dear Stafford Thank you very much for your explanation.Logically i taking 5% values from one distribtuion i.e 5 values out of 100 as sample size is 100.Similarly 95% values from other normal distribution which means 95 values out of 100.How can i do this?Your logic i did not understand
zahid
zahid 2016년 5월 6일
Thank your Roger Stafford now i have get your point.The logic which you are using is true in probability sense.
Regards

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by