用R语言生成服从正态分布的随机数,并画出直方图。
#-----Set a random number seed
set.seed(567)
#-----Generating random numbers that obey normal distribution
x<-rnorm(1000000,0,1)
#-----Draw a histogram
hist(x)
效果图

该博客介绍了如何利用R语言的set.seed()函数设定随机数种子,然后使用rnorm()函数生成大量服从标准正态分布的随机数,并通过hist()函数绘制直方图,展示正态分布的特性。此过程对于理解和模拟统计学中的正态分布概念十分有用。
用R语言生成服从正态分布的随机数,并画出直方图。
#-----Set a random number seed
set.seed(567)
#-----Generating random numbers that obey normal distribution
x<-rnorm(1000000,0,1)
#-----Draw a histogram
hist(x)
效果图

您可能感兴趣的与本文相关的镜像
HunyuanVideo-Foley
HunyuanVideo-Foley是由腾讯混元2025年8月28日宣布开源端到端视频音效生成模型,用户只需输入视频和文字,就能为视频匹配电影级音效
1398
384
3368
9534

被折叠的 条评论
为什么被折叠?