Processor

【Numpy】 난수(랜덤넘버)의 생성

작성자 임베디드코리아 작성일26-04-15 01:06 조회94회 댓글0건
<* Numpy 난수(랜덤넘버)의 생성 *>

[ 1 ] 균등분포에서 난수생성

---< 예시 >-------------------------------------
x = np.random.uniform(size=100)
x.reshape(20,5)
__________________________________________________________
## array([[0.62283254, 0.83247702, 0.69284631, 0.36343642, 0.1194816 ],
##        [0.95766884, 0.96097382, 0.82350006, 0.11160819, 0.54375729],
##        [0.24869946, 0.92595691, 0.99723618, 0.99178697, 0.23498384],
##        [0.39983813, 0.32569314, 0.7650107 , 0.61846918, 0.36615931],
##        [0.48812842, 0.78436822, 0.68059491, 0.17950023, 0.888353  ],


[ 2 ]  정규분포
---< 예시 >-------------------------------------
s = np.random.normal(0, 1, 1000)

import matplotlib.pyplot as plt
plt.hist(s)
_______________________________________________
## (array([  9.,  28.,  91., 183., 245., 219., 151.,  54.,  15.,  5.]), array([-2.95437005, -2.3291265 , -1.70388296, -1.07863942, -0.45339587,
##        0.17184767,  0.79709121,  1.42233476,  2.0475783 ,  2.67282184,
##        3.29806539]), <a list of 10 Patch objects>)

plt.show()
정규분포 그래프