In machine learning tasks. We should get a group of random w.r.t normal distribution with a bound. We can get a normal distribution number with np.random.normal() but it doesn't offer any bound parameter. I want to know how to do that?

Login

0 votes

It is quite complex to parametrize the **truncnorm class**. Here is an example that would help you to do so:

**For example:**

from scipy.stats import truncnorm

def get_truncated_normal(mean=0, sd=1, low=0, upp=10):

return truncnorm(

(low - mean) / sd, (upp - mean) / sd, loc=mean, scale=sd)

Hope this answer helps.