Random numbers generation

## Random numbers with SN or ST distribution

A recurrent question is: how can I generate pseudo-random numbers with skew-normal (SN), or skew-t (ST), distribution?

Solution A
Download the R 'library sn' and use the functions rsn or rmsn for the SN univariate and multivariate case, respectively. For the ST distribution, use rst and rmst. The master version of the library is the one for the computing environment R; this is available as public domain software, from CRAN.

The Matlab version provides facilities for the SN distribution only (univariate and multivariate), not for the ST distribution.

Solution B
If you want to write a program yourself, there are various algorithms; the following solution is based on one of these alternatives.

Consider first the scalar SN case.

1. Sample having marginal distribution N(0,1) and correlation . A simple way to achieve this is to generate as independent N(0,1) variates and define .
2. Then

is a random number sampled from the SN distribution with shape parameter .
3. To change the location and scale from (0,1) to (a,b) with b>0, say, set y=a+b z.

Consider now the bivariate SN case; the general multivariate case is similar.
1. Sample all having marginal N(0,1) distribution and correlation matrix

.

2. Then

is a random vector sampled from the bivariate SN distribution with (vector) shape parameter
,    where
For mathematical details and the general multivariate case, see Proposition 1 of Azzalini & Capitanio (1999).
3. If required, change the location and scale of z, similarly to the scalar case; this must be done component by component.

To obtain a ST variate, generate and put ; then w has ST distribution with degrees of freedom and shape parameter equal to the one of z. This works both for z scalar or multivariate. Again, this can be followed by scale and location change of w. For mathematical details, see Section 4 of Azzalini & Capitanio (2003).

Solution C