โมดูล random ในแพ็กเกจ NumPy มีฟังก์ชันมากมายสำหรับการสร้างตัวเลขสุ่ม
numpy.random.rand() - สร้างอาร์เรย์ตามรูปร่างที่กำหนดและเติมด้วยตัวอย่างสุ่ม
>>> import numpy as np
>>> np.random.rand(3, 2)
array([[0.10339983, 0.54395499],
[0.31719352, 0.51220189],
[0.98935914, 0.8240609 ]])
numpy.random.randn() - คืนค่าตัวอย่าง (หรือตัวอย่างหลายตัว) จากการแจกแจง "Standard Normal"
>>> np.random.randn()
-0.6808986872330651
numpy.random.randint() - คืนค่าจำนวนเต็มสุ่มจาก low (inclusive) ถึง high (exclusive)
>>> np.random.randint(5, size=(2, 4))
array([[2, 4, 0, 4],
[3, 4, 1, 2]])
numpy.random.random() - คืนค่า float สุ่มในช่วงครึ่งเปิด [0.0, 1.0)
>>> np.random.random_sample()
0.054638060174776126