Skills/Pythons
[Numpy] np.random.normal/randn
Suyeon Cha
2023. 3. 4. 20:26
728x90

normal과 randn이 헷갈려서 정리
넘파이의 랜덤 샘플링하는 함수이고, 원하는 분포를 만들 수 있습니다.
1. np.random.normal - 정규분포
- Draw random samples from a normal (Gaussian) distribution.
- Returns: ndarray or scalar
2. np.random.randn - 표준정규준포
- Return a sample (or samples) from the “standard normal” distribution.
- Returns: ndarray or float
따라서 평균이 0이고 표준편차가 1인 표준정규분포를 만들어 주기 위해선
import numpy as np
# numpy.random.normal
np.random.normal(0, 1, size)
# numpy.random.randn
np.randoom.randn(d0, d1, ..., dn) # parameters: the dimensions of the returned array
728x90