**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.

- 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 .
- Then
- To change the location and scale from (0,1) to
(a,b) withb>0 , say, sety=a+b z .

- Sample
all having marginal N(0,1) distribution and correlation matrix
.

- 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). - 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**- Click here

Go back to the
Skew-Normal distribution