使用R生成具有iid正态随机变量的矩阵 [英] Generate matrix with iid normal random variables using R
本文介绍了使用R生成具有iid正态随机变量的矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以在不使用循环的情况下用R生成具有正态分布的随机值的数据集?每个条目将代表一个具有正态分布的独立随机变量.
Is there a way to generate a data set with normally distributed random values in R without using a loop? Each entry would represent an independent random variable with a normal distribution.
推荐答案
要通过iid正常随机变量的M
矩阵创建N
,请输入以下内容:
To create an N
by M
matrix of iid normal random variables type this:
matrix( rnorm(N*M,mean=0,sd=1), N, M)
根据需要调整平均值和标准偏差.
tweak the mean and standard deviation as desired.
这篇关于使用R生成具有iid正态随机变量的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文