产生均值为0,方差 σ^2 = 1,标准差σ = 1的正态分布的随机数或矩阵的函数。

Example:产生一个随机分布的指定均值和方差的矩阵:将randn产生的结果乘以标准差,然后加上期望均值即可。例如,产生均值为0.6,方差为0.1的一个5*5的随机数方式如下:

x = .6 + sqrt(0.1) * randn(5)

x =

0.8713    0.4735    0.8114    0.0927    0.7672

0.9966    0.8182    0.9766    0.6814    0.6694

0.0960    0.8579    0.2197    0.2659    0.3085

0.1443    0.8251    0.5937    1.0475   -0.0864

0.7806    1.0080    0.5504    0.3454    0.5813

其他类似函数:rand, randperm, sprand, sprandn

randn

Normally distributed random numbers and arrays

Syntax

Y = randn(n)

Y = randn(m,n)

Y = randn([m n])

Y = randn(m,n,p,...)

Y = randn([m n p...])

Y = randn(size(A))

randn

s = randn('state')

Description

The randn function generates arrays of random numbers whose elements are normally distributed with mean 0, variance σ^2 = 1 , and standard deviation σ = 1.

Y = randn(n) returns an n-by-n matrix of random entries. An error message appears if n is not a scalar. Y = randn(m,n) or Y = randn([m n]) returns an m-by-n matrix of random entries. Y = randn(m,n,p,...) or Y = randn([m n p...]) generates random arrays. Y = randn(size(A)) returns an array of random entries that is the same size as A. randn, by itself, returns a scalar whose value changes each time it's referenced. s = randn('state') returns a 2-element vector containing the current state of the normal generator. To change the state of the generator: randn('state',s)Resets the state to s. randn('state',0)Resets the generator to its initial state. randn('state',j)For integer j, resets the generator to its jth state. randn('state',sum(100*clock))Resets it to a different state each time.ExamplesExample 1. R = randn(3,4) may produce  R =

1.1650    0.3516    0.0591    0.8717

0.6268   -0.6965    1.7971   -1.4462

0.0751    1.6961    0.2641   -0.7012

For a histogram of the randn distribution, see hist. Example 2. Generate a random distribution with a specific mean and variance . To do this, multiply the output of randn by the standard deviation , and then add the desired mean. For example, to generate a 5-by-5 array of random numbers with a mean of .6 that are distributed with a variance of 0.1 x = .6 + sqrt(0.1) * randn(5)

x =

0.8713    0.4735    0.8114    0.0927    0.7672

0.9966    0.8182    0.9766    0.6814    0.6694

0.0960    0.8579    0.2197    0.2659    0.3085

0.1443    0.8251    0.5937    1.0475   -0.0864

0.7806    1.0080    0.5504    0.3454    0.5813

See Also rand, randperm, sprand, sprandn

[本帖最后由 treeman 于 2010-10-14 22:22 编辑]

matlab randn 范围,请问randn产生的数据在什么范围内变化相关推荐

  1. MatLab中rand randi randn 三个函数的解析

    MatLab中rand randi randn 三个函数的解析 1.rand 概括:生成(0,1)之间的均匀分布的伪随机数 示例1: >>rand %什么参数也没有,生成一个(0,1)的数 ...

  2. MATLAB之rand、randn、randi和randperm

    参考 https://ww2.mathworks.cn/help/matlab/random-number-generation.html 整理MATLAB生成随机数的一些函数及其用法,以供查阅. 函 ...

  3. matlab生成多组多维高斯分布数据

    matlab生成多组多维高斯分布数据 之所以写这么一个函数,是因为在练习用matlab实现聚类分析,用matlab生成的高斯分布数据可以作为很好的数据.当然,直接load进鸢尾花数据集也可以拿来练手, ...

  4. matlab生成二维服从高斯分布的数据

    matlab生成二维服从高斯分布的数据 2015-12-30 21:31 1263人阅读 评论(0) 收藏 举报  分类: matlab(8)  由于实验需要,需要生成两类模式的数据,同时这两类数据要 ...

  5. matlab数据显示格式,如何使用MATLAB以图形格式记录和显示数据

    图形表示形式总是有助于可视化数据,并且通过查看趋势和模式非常容易.有很多软件可以根据输入值绘制图形,但是在嵌入式系统中,MATLAB是最受欢迎的软件之一,它不仅可以以图形形式显示结果,而且可以轻松地与 ...

  6. matlab数据变成一列数据,matlab读取excel表格列数据-matlab导入excel后,怎么把数据提取成一列?...

    怎么用matlab读取excel表格中的一列十六进制数据? x=xlsread('oillack.xls','sheet1','a1:a73') excel文件名是oillack.xls,sheet1 ...

  7. MATLAB中把Excel数据矩阵化,excel将表格数据矩阵-MATLAB怎么读取EXCEL中矩阵形式的数据,并存放在一......

    求EXCEL表格高手,如何在已知矩阵中,符合矩阵内条... =SUM((B$8=TRANSPOSE(OFFSET($B$1:$C$1,MATCH($A9,$A$2:$A$6,),)))*1) 数组公输 ...

  8. matlab换挡程序,一种基于MATLAB换挡过程中快速锁定分析数据的方法与流程

    本发明涉及汽车变速器数据分析,特别的,涉及一种基于matlab换挡过程中快速锁定分析数据的方法. 背景技术: 自动变速器的核心功能是能根据驾驶员意图进行自动换挡,解放驾驶员的左脚:在自动变速器的使用过 ...

  9. matlab读Excel表格数据画图,matlab读Excel表格数据画图-matlab如何从excel表格中读取数据?...

    如何将excel表格中大量数据导入matlab中并作图 1.打开matlab,点击主页下面的数据导入,你可以导入excel数据,这里导入你自己命名的huitushuju文件. 2.单击"打开 ...

最新文章

  1. 这份“插件英雄榜Top20”才是Chrome的正确打开方式!
  2. exp oracle所有数据库命令,oracle数据库exp命令
  3. libpcap的简单使用--抓取特定类型和端口的网络数据
  4. 过多提交(Over Posting)
  5. 模糊查询一--视图写sql
  6. Unity3D之NGUI基础7:UI动态加载
  7. mysql innodbdatahomedir_mysql gtid复制
  8. Web系统集成OCS在线状态功能
  9. win7一直卡在首次使用计算机,重装win7一直停留在正在启动windows解决方法(完美解决)...
  10. nfc卡模式与标准模式_NFC相关标准
  11. Jsp与Servlet面试题
  12. 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式
  13. bitset优化传递闭包
  14. 支付宝支付demo运行流程
  15. 2032:【例4.18】分解质因数
  16. for循环和嵌套循环
  17. 5、zookeeper四字监控命令/配置属性
  18. 服务熔断 Hystrix
  19. 中国移动互联网测试开发大会(简称MTSC大会)
  20. Pr 入门教程:了解基本用户界面

热门文章

  1. ASP.NET 應用程式的安全性模型
  2. Hey, everybody!
  3. NET框架下如何使用PaddleOCRSharp
  4. 如何将 image 转成 base64 字符串?
  5. 太神奇了!使用C#实现自动核验健康码:(2)OCR识别
  6. 巧用定时任务监控第三方组件是否正常
  7. 还在犹豫是否迁移.NET5?这几个项目已经上线了!
  8. Net5 已经来临,让我来送你一个成功
  9. 秋天 | 等疫情过后,我们继续背起相机去旅行
  10. 初识ABP vNext(1):开篇计划基础知识