728x90
넘파이 난수 생성
import numpy as np
numpy.random.rand(d0,d1,...)
>>> a = np.random.rand()
>>> a
0.8265127132486283
>>> b = np.random.rand(10)
>>> b
array([0.52378504, 0.35727214, 0.35869626, 0.58862312, 0.39184057,
0.49020887, 0.64360582, 0.08130151, 0.12713493, 0.42913997])
numpy.random.randn(d0, d1, ..., dn)
>>> c = np.random.randn()
>>> c
0.21423335992324902
>>> d = np.random.randn(10)
>>> d
array([-1.28840094, -2.03541272, -1.08534621, -0.3659988 , 2.13054496,
-0.37173855, 0.19194732, 0.91521406, -0.85081639, -0.68821558])
>>> e = np.random.randn(10,1)
>>> e
array([[-0.17924635],
[ 1.09098268],
[ 1.10546769],
[-0.78903644],
[ 1.29073505],
[-1.08213603],
[-1.08580595],
[-0.34082787],
[ 0.10444354],
[ 0.08724687]])
numpy.random.randint(low, high=None, size=None, dtype='l')
>>> np.random.randint(5, size=(2, 4))
array([[4, 0, 2, 1],
[3, 2, 2, 0]])
- 0,1로 이루어진 난수 생성
>>> np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0])
https://docs.scipy.org/doc/numpy-1.15.0/index.html
728x90
'programming language > Python' 카테고리의 다른 글
[Python] Colab Selenium - 코랩 셀리니움 사용법 (0) | 2020.11.26 |
---|---|
[Python] 파이썬 넘파이 (Numpy) - numpy.log1p() / numpy.expm1() (0) | 2020.10.22 |
[Python] 넘파이 (Numpy) - 공부하기_Numpy.c_ .2 (0) | 2020.10.20 |
[python] 파이썬 판다스 - python pandas - pd.cut() (0) | 2020.10.12 |
[python] 판다스 날짜 데이터 타입 변환 - pandas / to_datetime() (2) | 2020.10.08 |