ABOUT ME

Today
Yesterday
Total
  • numpy의 rand와 randn의 차이
    머신러닝 및 딥러닝 2020. 8. 9. 22:54

    numpy에서 항상 궁금했었던 것이 있다.

     

    import numpy as np

    A=np.random.rand
    B=np.random.randn

    이 둘의 차이는 무엇일까??

     

     

     

     

    randn

    • Return a sample (or samples) from the “standard normal” distribution.

    표준 정규 분포 ( N(0,1) 즉, 평균이 0이고 표준편차가 1인 분포) 에서 추출한 샘플을 리턴한다. 따라서 음수의 값이 나올 수 있다.

     

     

    rand

    • Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

    즉, 0은 들어가지만 1은 들어가지 않는 균등분포(각각의 변수가 나올 확률이 똑같은 분포)로 부터 랜덤한 샘플을 추출하여 배열을 반환해주는 것이다. 따라서 음수의 값이 나올 수 없다.

    '머신러닝 및 딥러닝' 카테고리의 다른 글

    nn.Module에서 super  (1) 2021.01.10
    np.zeros 와 np.zeros_like 의 차이  (0) 2021.01.06
    NLP 에서의 embedding size  (0) 2021.01.01
    Beam Search  (0) 2020.12.22
    시계열 데이터란?  (0) 2020.08.08

    댓글