how can I generate data mixture of 2 Normal distributions and has the form f(x) = 0.4X1 + 0.6X2 where X1 ~ N(0.4 ,0.15^2) and X2 ~ N(0.7 , 0.09^2)?

11 ビュー (過去 30 日間)
i need help to generate data from two mixture normal distributions of the denstiy function f(x)=0.4*x1+0.6*x2 where x1~N(0.4,0.15^2) & x2~N(0.7,0.09^2)
  1 件のコメント
the cyclist
the cyclist 2018 年 12 月 21 日
I interpreted what you wrote a little bit differently from the math you actually wrote. Did you mean that you want there to be 40% probability that the draw is from x1, and 60% that it is from x2? (That's what I assume you meant.)

サインインしてコメントする。

採用された回答

the cyclist
the cyclist 2018 年 12 月 21 日
編集済み: the cyclist 2018 年 12 月 21 日
Here is one way:
% The number of random samples to generate
N = 10000;
% First, generate a binomial variable, which 40% of the time (on average) will be equal to 1,
% and 60% of the time (on average) will be equal to zero.
frac = rand(N,1) < 0.4;
% Generate the two normal distributions to sample from
norm1 = 0.4 + 0.15*randn(N,1);
norm2 = 0.7 + 0.09*randn(N,1);
% If "frac" is equal to 1, then the choice will be from the first normal.
% If "frac" is equal to 0, then the choice will be from the second normal.
d = frac.*norm1 + (1-frac).*norm2;
% Plot the resulting distribution
figure
histogram(d)
  5 件のコメント
Deepak Kumar
Deepak Kumar 2019 年 3 月 11 日
what we will do, if we need to calculate (N1 / N2) distribution?
Torsten
Torsten 2019 年 3 月 11 日
What do you mean by "calculate" ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by