Tell me more ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I can find the

random('normal', 0, 1, 10000,1)

command in MATLAB but it generates half-normal variates. I would like to generate random half-normal variates. The half-normal distribution is defined by

$$f_{|Z|}(x)=\frac{2}{\sqrt{2\pi}}e^\frac{-x^{2}}{2}.$$

Can I generate a random half-normal variates from random normal variates?

share|improve this question

1 Answer

As Wikipedia says, you can just compute a normally distributed random variable with a mean of zero and take the absolute value. The half-normal probability distribution function is identical to the normal PDF with $\mu = 0$ for $X > 0$, except for a factor of two for the normalization.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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