dmvnorm(x, mean=rep(0,d), cov=diag(d), sd, rho) pmvnorm(q, mean=rep(0,d), cov=diag(d), sd, rho) rmvnorm(n, mean=rep(0,d), cov=diag(d), sd, rho, d=2, bigdata=F)
d
, or matrix with
d
columns, containing
d
-dimensional quantiles.
d
to return
(as rows in a matrix).
d
, or matrix with
n
rows and
d
columns.
d
rows and columns.
d
, or matrix with
n
rows and
d
columns,
containing standard deviations.
If supplied, the rows and columns of
cov
are multiplied by
sd
.
In particular, if
cov
is a correlation matrix and
sd
is a
vector of standard deviations, the result is a covariance matrix.
If
sd
is a matrix then one row is used for each observation.
bdVector
of length
n
,
containing correlations for bivariate data.
This is ignored if
cov
is supplied.
TRUE
, an object of type
bdVector
is returned.
Otherwise, a
vector
object is returned. This argument can be used only if the bigdata library section has been loaded.
dmvnorm
),
probability (
pmvnorm
), or
random sample (
rmvnorm
)
for the multivariate normal distribution.
For
rmvnorm
the result is a matrix with
n
rows and
d
columns,
and for the other functions the result is a vector or
bdVector
of length
n
.
The probability returned by
pmvnorm
is the multivariate cumulative
distribution function, e.g. P(X < q[1], Y < q[2]) for bivariate data.
rmvnorm
cause creation of the
dataset
.Random.seed
if it does not already exist,
otherwise its value is updated.
The values of
n
and
d
are inferred from the dimensions
of
x
,
q
,
mean
,
sd
, and
rho
.
pmvnorm
currently allows bivariate (
d=2
) data only,
unless all covariances are zero.
Missing values (NAs) are allowed in arguments
x
and
mean
,
except when calling
pmvnorm
.
The random values returned by
rmvnorm
depend on both
cov
and
sd
.
The (co)variances of the random values, and the results of
dmvnorm
and
pmvnorm
, depend only on the
result of multiplying the rows and columns of
cov
by rows of
sd
.
It is generally more efficient to generate a matrix of random values in a
single call to
rmvnorm
than to call the function repeatedly in a loop.
For details on the uniform random number generator implemented in S-PLUS,
see the
set.seed
help file.
Donnelly, T. G. (1973).
Algorithm 462, Bivariate normal distribution.
Commun. Ass. Comput. Mach.
16, 636-638.
Ripley, B.D. (1987)
Stochastic Simulation.
Wiley. Page 98.
rmvnorm(5) # 5 rows and 2 independent columns rmvnorm(5, mean=c(9,3,1)) # 5 rows and 3 independent columns rmvnorm(5, rho=.9) # 2 columns, std. dev. 1, correlation .9 rmvnorm(5, mean=c(9,3), cov=matrix(c(4,1,1,2), 2)) pmvnorm(c(1,2), rho=.3) pmvnorm(c(1,2), rho=c(.3,.4,.5)) dmvnorm(c(1,2), rho=.3) dmvnorm(c(1,2), rho=c(.3,.4,.5)) x <- seq(-3,3,length=10) # Evaluate density at 10*10*10 grid array(dmvnorm(x=cbind(rep(x, 100), rep(x, 10, each=10), rep(x, each=100)), cov=cbind(c(5,1,2), c(1,3,1), c(2,1,9))), dim=c(10,10,10))