NumPy 之 案例(随机漫步)
import numpy as np The numpy.random module supplements(补充) the built-in Python random with functions for efficiently generating whole arrays of sample values from many kinds of probalility distributions. For example, you can get a 4x4 array of samples from the standard normal distribution using normal: samples = np.random.normal(size=(4,4)) samples array([[-0.49777854, 1.01894039, 0.3542692 , 1.0187122 ], [-0.07139068, -0.44245259, -2.05535526, 0.49974435], [ 0.80183078, -0.11299759, 1.22759314, 1.37571884], [ 0.32086762, -0.79930024, -0.31965109, 0.23004107]]) Python's built-in random module,