How do you sample from a half-normal distribution in Python? I would like to generate samples from a half normal distribution.
numpy's random number generator allows you to sample from many distributions. Here's an example for the normal distribution. However, it does not appear to support half-normal. I could take the absolute value of the samples, but this seems inelegant.
import numpy as np
import matplotlib.pyplot as plt 

samples = np.random.normal(0, 1, size=1000)
plt.hist(samples)

scipy contains a half-normal distribution (halfnorm), but I can't figure out if you are able to sample from this.
from scipy.stats import halfnorm, norm


The documentation states the rvs method to calculate random variables from a half-normal distribution. For example:
from scipy.stats import halfnorm, norm
x = halfnorm.rvs(loc = 0, scale = 1, size=1000)

Here, loc specifies the location and scale the scale parameters.
