0 votes
1 view
in Machine Learning by (19k points)

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?

1 Answer

0 votes
by (33.2k points)

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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...