在Matlab中的列向量中创建一个双峰分布到相等的和

时间:2017-09-13 14:09:54

标签: matlab distribution

我试图在Matlab中生成一个列向量(nx1),其值具有双峰分布。我希望列向量中的所有值总和为一个指定值,并且能够指定分布中的最小值和最大值。

谢谢!

1 个答案:

答案 0 :(得分:0)

双峰分布是具有两个峰的分布,即两个正态分布的叠加:

n = 100;
X = 1:n;
PDF = normpdf(X, 30, 5) + 5*normpdf(X, 60, 10); % take the combination of two normal distrubtions
PDF = PDF/sum(PDF); % normalise it, i.e. sum equals to one.

figure
plot(X, PDF); % plot the result

enter image description here