Description Usage Arguments Details Value Author(s) References Examples

Fast simulation of multivariate Student's t random variables

1 |

`n` |
number of random vectors to be simulated. |

`mu` |
vector of length d, representing the mean of the distribution. |

`sigma` |
scale matrix (d x d). Alternatively it can be the cholesky decomposition
of the scale matrix. In that case isChol should be set to TRUE. Notice that ff the degrees of
freedom (the argument |

`df` |
a positive scalar representing the degrees of freedom. |

`ncores` |
Number of cores used. The parallelization will take place only if OpenMP is supported. |

`isChol` |
boolean set to true is |

`A` |
an (optional) numeric matrix of dimension (n x d), which will be used to store the output random variables.
It is useful when n and d are large and one wants to call |

There are in fact many candidates for the multivariate generalization of Student's t-distribution, here we use the parametrization described here https://en.wikipedia.org/wiki/Multivariate_t-distribution.

Notice that `rmvt()`

does not use one of the Random Number Generators (RNGs) provided by R, but one
of the parallel cryptographic RNGs described in (Salmon et al., 2011). It is important to point out that this
RNG can safely be used in parallel, without risk of collisions between parallel sequence of random numbers.
The initialization of the RNG depends on R's seed, hence the `set.seed()`

function can be used to
obtain reproducible results. Notice though that changing `ncores`

causes most of the generated numbers
to be different even if R's seed is the same (see example below). NB: at the moment the RNG does not work
properly on Solaris OS when `ncores>1`

. Hence, `rmvt()`

checks if the OS is Solaris and, if this the case,
it imposes `ncores==1`

.

If `A==NULL`

(default) the output is an (n x d) matrix where the i-th row is the i-th simulated vector.
If `A!=NULL`

then the random vector are store in `A`

, which is provided by the user, and the function
returns `NULL`

.

Matteo Fasiolo <matteo.fasiolo@gmail.com>, C++ RNG engine by Thijs van den Berg <http://sitmo.com/>.

John K. Salmon, Mark A. Moraes, Ron O. Dror, and David E. Shaw (2011). Parallel Random Numbers: As Easy as 1, 2, 3. D. E. Shaw Research, New York, NY 10036, USA.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
d <- 5
mu <- 1:d
df <- 4
# Creating covariance matrix
tmp <- matrix(rnorm(d^2), d, d)
mcov <- tcrossprod(tmp, tmp) + diag(0.5, d)
set.seed(414)
rmvt(4, 1:d, mcov, df = df)
set.seed(414)
rmvt(4, 1:d, mcov, df = df)
set.seed(414)
rmvt(4, 1:d, mcov, df = df, ncores = 2) # These will not match the r.v. generated on a single core.
###### Here we create the matrix that will hold the simulated random variables upfront.
A <- matrix(NA, 4, d)
class(A) <- "numeric" # This is important. We need the elements of A to be of class "numeric".
set.seed(414)
rmvt(4, 1:d, mcov, df = df, ncores = 2, A = A) # This returns NULL ...
A # ... but the result is here
``` |

mvnfast documentation built on May 30, 2017, 4:30 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.