For teaching purposes I'm trying to generate some probability distributions that have varying amounts of skew but precisely controllable mean and variance. I'd like to plot these distributions and also sample from them.

The skew-normal distribution and its R implementation almost fit the bill except that the skew, mean, and variance parameters can't be controlled independently. Changing the skew also changes the mean and variance. For example

x <- seq(-4, 4, by = .01)
y <- dsn(x, xi = 0, omega = 1, alpha=4)

Skew normal distribution

here you can see that modifying the skew-related parameter (alpha) also changed the mean of the distribution to a positive value.

I'd like to be able to modify the skew while keeping the mean at 0 and the variance at 1, or while holding the mean and variance at other specified values.

Any advice on how to do this?

  • 3
    $\begingroup$ You could simply solve the two equations of the mean and variance for the skew-normal distribution. For a mean of $0$ and a variance of $1$, you'll get $\xi = -\frac{\sqrt{2}\alpha}{\sqrt{\pi + (-2 + \pi)\alpha^{2}}}$ and $\omega = \frac{\sqrt{\pi}\sqrt{1+\alpha^2}}{\sqrt{\pi + (-2 + \pi)\alpha^{2}}}$. $\alpha$ can be chosen freely. An easier example of a skewed distribution would simply be the gamma distribution. $\endgroup$ Nov 5, 2022 at 13:55
  • 4
    $\begingroup$ There are many skewed families to choose from; some separate some form of skewness (such as third-moment-based skewness) from mean and variance - for example, the Pearson family, about which there are quite a few posts here already, as well as a Wikipedia article. You can then scale (including sign-flip to change the direction of skewness) and shift as desired. Having some flexible family that allows you to match the first few moments does not necessarily mean that the resulting distribution is a good match for another distribution with similar moments. $\endgroup$
    – Glen_b
    Nov 5, 2022 at 14:56

1 Answer 1


except that the skew, mean, and variance parameters can't be controlled independently

Not true :-). With the function cp2dp of the sn package, you can convert from the population mean, the population standard deviation and the population skewness to the parameters xi, omega and alpha of the skew-normal distribution.

params <- cp2dp(c(5, 2, -0.5), "SN")
#        xi     omega     alpha 
#  7.104419  2.903201 -2.173758 

sims <- rsn(5000L, dp = params)
mean(sims) # approx 5
sd(sims) # approx 2

x <- seq(-2, 10, length.out = 500)
y <- dsn(x, dp = params)
plot(x, y, type = "l")

enter image description here

Note that the SN family only supports skewness between -0.99527 and 0.99527. Outside of this range, the ST family is needed, which requires a fourth parameter: the kurtosis.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.