 # What does the np.random.normal() function return?

### Question

In the context of this exercise, what does the `np.random.normal()` function return?

The `np.random.normal()` function returns a list of random samples drawn from a normal distribution.

The distribution is dependent on the values of the keyword arguments `loc`, `scale`, and `size`.

The number of samples in this returned list will be equal to the value of the `size` argument.

Furthermore, each time you run this function, the results will be slightly different each time, due to the randomness, but will follow the same distribution and general shape. To ensure that the result is more accurate, it is good to choose a large size value, which usually is around `10000`.

5 Likes

Probably it’s worth to mention, that `np.random.normal` return NumPy array of random samples, not a list (`class 'numpy.ndarray'`) which is easy to check with `type()` function.

6 Likes

How does np.random.normal() determine the corresponding Y value/dependent variable? Is that also totally random?

I had the same doubt as you, but I realized I was looking at histograms the wrong way. Always remember that in a histogram, the height of each bin ( or Y ) is determined by the number of samples that fall within the range of each bin.

Hope it helps, cheers! 