Matlab中产生正态分布随机数的函数normrnd-----用来产生高斯随机矩阵



Matlab中产生正态分布随机数的函数normrnd-----用来产生高斯随机矩阵  


功能:生成服从正态分布的随机数
语法:
R=normrnd(MU,SIGMA)
R=normrnd(MU,SIGMA,m)
R=normrnd(MU,SIGMA,m,n)

  说 明:
R=normrnd(MU,SIGMA):生成服从正态分布(MU参数代表均值,DELTA参数代表标准差)的随机数。输入的向量或矩阵MU和SIGMA必须形式相同,输出R也和它们形式相同。标量输入将被扩展成和其它输入具有 相同维数的矩阵。

  R=norrmrnd(MU,SIGMA,m):生成服从正态分布(MU参数代表均值,DELTA参数代表标准差)的 随机数矩阵,矩阵的形式由m定义。m是一个1×2向量,其中的两个元素分别代表返回值R中行与列的维数。

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

  
>> help normrnd
NORMRND Random arrays from the normal distribution.
R = NORMRND(MU,SIGMA) returns an array of random numbers chosen from a
normal distribution with mean MU and standard deviation SIGMA.  The size
of R is the common size of MU and SIGMA if both are arrays.  If either
parameter is a scalar, the size of R is the size of the other
parameter.

R = NORMRND(MU,SIGMA,M,N,...) or R = NORMRND(MU,SIGMA,[M,N,...])

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

  例:生成正态分布随机数。
>> a=normrnd(0,1)

  a =

     -1.4814

  >> a=normrnd(0,1,1,6)

  a =

      1.1287   -0.2900    1.2616    0.4754    1.1741    0.1269

  >> a=normrnd(0,1,[1 6])

  a =

      0.1555    0.8186   -0.2926   -0.5408   -0.3086   -1.0966

  >> a=normrnd(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)
plot(x,y)
subplot(2,1,2)
% z=normrnd(50,2,100,1);
% plot(z)
z=0:1:100;
d=normpdf(z,50,2);
plot(z,d)

,等价表达

  • 13
    点赞
  • 66
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值