Codes

朱琪 · December 30, 2020

random module in numpy:

import numpy as np x = np.random.randint(100) x = np.random.rand() x = np.random.randint(100, size=(3,5)) x = np.random.rand(3,5) x = np.random.choice([2,3,4,5]) x = np.random.choice([2,3,4,5], size=(2,5))

x = np.random.choice([3,5,7,9], p=[0.1, 0.3, 0.6, 0.0], size=(3,5))

arr = np.array([1,2,3,4,5]) np.random.shuffle(arr) np.random.permutation(arr)

import matplotlib.pyplot as plt import seaborn as sns

x = np.random.normal(loc=1, scale=2, size=(2,3))

Twitter, Facebook