How can i select random sample from mixture of two normal distributions in MATLAB ?
4 次查看(过去 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.
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!