Using Python, generate 100x100 random matrix whose entries are sampled from the normal distribution.

856 Views Asked by At

Generate random vectors using numpy.random. Write code in Python that produces a $100 \times 100$ random matrix whose entries are samples from the normal distribution.


This is what I produced and am unsure if this is correct. I have a question on normal distribution as well. Should my random numbers come from a certain pool? Such as $[0,1]$ or is it possible to get values out of this range?

This is the code if wrote in Jupyter Notebook

If anyone knows a better way to post Python code, I would also appreciate that.

1

There are 1 best solutions below

1
On BEST ANSWER

Your method is correct. You could do:

from matplotlib import pyplot as plt
plt.hist(a.reshape(-1, 1))
plt.show()

to see a histogram which should reflect a bell curve. a.reshape(-1, 1) puts the matrix into a single vector.