rmvnorm(spam)
rmvnorm()所属R语言包:spam
Draw Multivariate Normals
绘制多变量平均值
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Fast ways to draw multivariate normals when the variance or precision matrix
快速的方法来绘制多元法线的方差或精度矩阵
用法----------Usage----------
rmvnorm.spam(n,mu=rep(0, nrow(Sigma)), Sigma, Rstruct=NULL, ...)
rmvnorm.prec(n,mu=rep(0, nrow(Q)), Q, Rstruct=NULL, ...)
rmvnorm.canonical(n, b, Q, Rstruct=NULL, ...)
参数----------Arguments----------
参数:n
number of observations.
若干意见。
参数:mu
mean vector.
均值向量。
参数:Sigma
covariance matrix of class spam.
类spam的协方差矩阵。
参数:Q
precision matrix.
精度矩阵。
参数:b
vector determining the mean.
矢量确定的意思。
参数:Rstruct
the Cholesky structure of Sigma or Q.
的的Cholesky结构Sigma或Q。
参数:...
arguments passed to chol.
参数传递到chol。
Details
详细信息----------Details----------
The functions rmvnorm.prec and rmvnorm.canonical do not require sparse precision matrices. For rmvnorm.spam, the differences between regular and sparse covariance matrices are too significant to be implemented here. <br> Often (e.g., in a Gibbs sampler setting), the sparsity structure of the covariance/precision does not change. In such setting, the Cholesky factor can be passed via Rstruct in which only updates are performed (i.e., update.spam.chol.NgPeyton instead of a full chol).
的功能rmvnorm.prec和rmvnorm.canonical不需要稀疏精度矩阵。对于rmvnorm.spam,定期和稀疏的协方差矩阵之间的差异是太显著实施。参考通常情况下(例如,在一个Gibbs采样设置),稀疏的协方差/精密的结构并没有改变。在这样的设置,的Cholesky因子可以通过使用Rstruct只进行更新(即,update.spam.chol.NgPeyton,而不是一个完整的chol,)。
(作者)----------Author(s)----------
Reinhard Furrer
参考文献----------References----------
参见----------See Also----------
chol and ordering.
chol和ordering。
实例----------Examples----------
# Generate multivariate from a covariance inverse:[生成多变量的协方差逆:]
# (usefull for GRMF)[(有用为GRMF)]
set.seed(13)
n <- 25 # dimension[尺寸]
N <- 1000 # sample size[样本量]
Sigmainv <- .25^abs(outer(1:n,1:n,"-"))
Sigmainv <- as.spam( Sigmainv, eps=1e-4)
Sigma <- solve( Sigmainv) # for verification [为验证]
iidsample <- array(rnorm(N*n),c(n,N))
mvsample <- backsolve( chol(Sigmainv), iidsample)
norm( var(t(mvsample)) - Sigma, type="m")
# compare with:[对比:]
mvsample <- backsolve( chol(as.matrix( Sigmainv)), iidsample, n)
#### ,n as patch [###,n为补丁]
norm( var(t(mvsample)) - Sigma, type="m")
# 'solve' step by step:[“解决”一步一步:]
b <- rnorm( n)
R <- chol(Sigmainv)
norm( backsolve( R, forwardsolve( R, b))-
solve( Sigmainv, b) )
norm( backsolve( R, forwardsolve( R, diag(n)))- Sigma )
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|