matlab舍选法产生随机数,根据任意概率密度函数产生随机数

我的已知概率密度函数为双峰高斯分布,由博客http://blog.renren.com/blog/20398/860904791给出了matlab程序。不过我将其函数增加了一个参数——能够修改长度的参数N.

文献(1997_蒋仁言_一种可有双峰形状的概率密度函数)给出的双峰概率密度函数的表达式非常麻烦,也不够直观。修改之后的matlab程序如下:

​function

p=twomodegauss(m1,sig1,m2,sig2,A1,A2,k,N)

%TWOMODEGAUSS Generates a bimodal

Gaussian function.

%

p=TWOMODEGAUSS(M1,SIG1,M2,SIG2,A1,A2,K) generates a

bimodal,

%   Gaussian-like

function in the interval [0,1]. P is a

N-element

%   vector normalized so

that SUM(P) equals 1.The mean and standard

%   deviation of modes

are (M1,SIG1) and (M2,SIG2),respectively.

%   A1 and A2 are the

amplitude values of two modes.Since the

%   output is

normalized,only the relative values of A1 and A2

are

%   important.K is an

offset value that raises the "floor" of the

%   function.A good set

of value to try is M1=0.15,SIG1=0.05,

%

M2=0.75,SIG2=0.05,A1=1,A2=0.07,and K=0.002.

% modified by WANG QIAO

,20150212​

c1=A1*(1/((2*pi)^0.5)*sig1);

k1=2*(sig1^2);

c2=A2*(1/((2*pi)^0.5)*sig2);

<


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部