Skip to content
Prev 307693 / 398503 Next

Help on probability distribution question

(I made a slip with the mulstivariate case below: see at [***])
On 11-Oct-2012 17:51:51 Ted Harding wrote:
If I understand your question correctly, if Y is the variable being
simulated then you know the mean (M, say) and the variance (V, say)
of log(Y). So you can simulate X from a normal distribution with
mean M and variance V = S^2 (S = SD of X), and then Y = exp(X):

  Y <- exp(rnorm(n,M,S))

where n is the number of sampled values you want.

When Y is multivariate, with M the vector of means and V the
covariance matrix of log(Y), then use a similar approach with
the function mvrnorm() from the MASS package:
[***]
##  library(MASS)
##  Y <- mvrnorm(n,M,V)
  library(MASS)
  Y <- exp(mvrnorm(n,M,V))

Does this help?
Ted.
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 11-Oct-2012  Time: 19:44:02
This message was sent by XFMail