首页 > 编程知识 正文

matlab生成正态分布随机变量,matlab

时间:2023-05-04 11:59:29 阅读:58242 作者:1368

原文功能:生成遵从正态分布的随机数

语法:

r=normrnd(mu,SIGMA ) ) ) ) ) ) ) ) ) ) )。

r=normrnd(mu,SIGMA,m ) ) ) ) ) )。

r=normrnd(mu,SIGMA,m,n )的说明:

r=normrnd(MU,SIGMA ) :根据正态分布(mu参数表示平均值,SIGMA参数表示标准差)生成随机数。 下一个向量或矩阵MU和SIGMA应当具有相同的形式,输出r也应当具有与它们相同的形式。 标量输入扩展为与其他输入相同的维矩阵。

r=norrmrnd(MU,SIGMA,m ) :根据正态分布(mu参数表示平均值,SIGMA参数表示标准差)生成随机数矩阵,其中矩阵的形状由m定义。 m是12向量,两个元素分别表示返回值为r的行和列的维数。

r=normrnd(mu,SIGMA,m,n ) :生成mn形式正态分布的随机数矩阵。

help normrnd

normrndrandomarraysfromthenormaldistribution。

r=Normrnd(mu,SIGMA ) returnsanarrayofrandomnumberschosenfroma

normaldistributionwithmeanmuandstandarddeviationsigma.thesize

ofristhecommonsizeofmuandsigmaifbotharearrays.ifeither

parameter is a scalar,the size of R is the size of the other

参数器

) ) ) )

returns an M-by-N-by-. array。

示例:生成正态分布随机数。

a=norm rnd (0,1 ) ) ) ) ) ) ) ) )。

a=

-1.4814

a=norm rnd (0,1,1,6 ) ) ) ) ) )。

a=

1.1287-0.29001.26160.47541.17410.1269

a=norm rnd (0,1,[1]6)

a=

0.15550.8186-0.2926-0.5408-0.3086-1.0966

a=norm rnd (10、2、2、3 ) ) ) ) ) ) ) )。

a=

13.6280 13.6090 11.0531

10.6240 8.5538 9.4795

m=50;

n=2;

x=0:1:100;

y=exp(-) x-m ).^2/(2* n ^2);

subplot (2,1,1 ) ) )。

打印(x,y ) )。

subplot (2,1,2 ) )

% z=norm rnd (50,2,100,1 );

%plot(z )

z=0:1:100;

d=NORMpdf(z,50,2 );

打印(z,d ) )。

、等价表现

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。