LoginSignup
2
4

More than 3 years have passed since last update.

NumpyのrandintとRandomのrandintの違い

Last updated at Posted at 2016-07-30
import numpy as np
import random as rd

np.random.randint(0, 10)
rd.randint(0,10)

Numpy を使用した場合の randint は上記の場合だと 0~9
Random を使用した場合の randint は上記の場合だと 0~10

Numpynumpy.random.randint(a, b) -> a から b-1
Randomrandom.randint(a, b) -> a から b

Numpyrange(a, b) と同じだから違和感なかったけど、
始めの頃は Random を多用していたのでこの仕様には驚かされた

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4