当前位置:   article > 正文

Numpy学习—np.random.randn()、np.random.rand()和np.random.randint()_rand(100,1

rand(100,1
具体请参考https://blog.csdn.net/zenghaitao0128/article/details/78556535
         https://www.cnblogs.com/hezhiyao/p/8065528.html
numpy.random.rand():的随机样本位于[0, 1)之间。
numpy.random.randn():是从标准正态分布中返回一个或多个样本值。这里的范围就是()
  1. import numpy as np
  2. arr1 = np.random.rand()
  3. print(arr1)
  4. arr2 = np.random.rand(100)
  5. print(arr2)
  6. arr3 = np.random.randn(100)
  7. print(arr3)
  8. arr4 = np.random.randn(2,4)
  9. print(arr4)
  10. a = np.random.randint(1,20,size=(4,4),dtype='uint8')
  11. print(a)
  1. D:\python北风\venv\Scripts\python.exe D:/python北风/numpy知识/rand&randn.py
  2. 0.0479076176680423
  3. [0.87837291 0.07926367 0.65228319 0.74214615 0.31661571 0.89140242
  4. 0.05047662 0.9253252 0.07251961 0.52202533 0.50888427 0.37820921
  5. 0.04236712 0.46426376 0.53527316 0.58262449 0.61006648 0.49541628
  6. 0.43751286 0.63990954 0.9493651 0.81081876 0.86252489 0.63378123
  7. 0.85045014 0.34305455 0.95988395 0.81430687 0.04737932 0.89658439
  8. 0.20494303 0.6576473 0.17954643 0.9222191 0.85664036 0.82701783
  9. 0.08395999 0.68592725 0.282314 0.01353303 0.67548876 0.315665
  10. 0.48156132 0.53915318 0.30430808 0.24890889 0.10561204 0.70063686
  11. 0.25957781 0.80885657 0.12388954 0.82421561 0.07006289 0.17652435
  12. 0.59553379 0.07637348 0.93409698 0.42555354 0.53145922 0.71552662
  13. 0.97351334 0.59782855 0.69139816 0.96967609 0.61883166 0.17801031
  14. 0.41158341 0.58421903 0.34617367 0.90771563 0.56460392 0.2129191
  15. 0.7745671 0.86280663 0.29979984 0.40010941 0.21837734 0.84418573
  16. 0.43121147 0.59969753 0.5830628 0.02316962 0.34081256 0.82783402
  17. 0.01218603 0.33755025 0.24113006 0.8289726 0.57715362 0.73419066
  18. 0.59747727 0.16836938 0.51082972 0.05404864 0.00199209 0.86954128
  19. 0.4267199 0.58042238 0.846229 0.33156209]
  20. [ 1.33561869 -0.51063063 -0.59563199 1.25852382 0.23896024 0.75628845
  21. 1.55630362 -1.03172239 0.433224 0.39148338 0.91128565 0.54640966
  22. 1.14936728 1.17457711 -0.81296807 1.45822674 -1.0692011 -0.60329903
  23. 1.35563171 -0.27272956 0.89339747 -0.06241945 -1.42203569 -1.14131527
  24. 1.00443776 -0.4491623 -0.39742472 -0.3835911 1.80797303 1.76542415
  25. -1.02412211 1.17747793 -1.04203081 -0.41387708 1.5886436 0.55311169
  26. -0.42442562 -0.57881306 0.21956656 1.10407211 -1.58014147 0.15370797
  27. 0.86177973 -0.50659637 0.02649642 2.03501869 1.62726556 -0.24300252
  28. 1.19767725 -0.27260052 -0.99379173 0.84603997 -1.12920113 0.09168563
  29. -1.17901478 -0.7227298 0.07387924 -0.18452718 1.17423448 -0.38513804
  30. -0.26402127 0.42014553 -0.6317797 -0.41556312 -0.92567353 1.04935611
  31. -0.09881773 -0.50814096 0.88119307 -2.19594063 1.04570995 -1.08911147
  32. -0.3450531 1.18488096 0.9312479 -0.13665565 -0.27044031 -0.64418195
  33. 0.87648905 -1.05162986 0.45551934 -0.53468467 -0.89227476 1.26401226
  34. -0.31181943 0.17022567 -1.70523099 0.99135907 0.62171189 -0.44967944
  35. 0.32577803 0.37729966 1.85502769 -0.36937509 -1.78293138 2.13513423
  36. 0.12735647 -0.64478542 0.39379421 -0.0581531 ]
  37. [[-2.16338208 0.85754668 0.49613056 -0.06990232]
  38. [ 1.39638219 -0.53690093 -1.51991701 1.32181066]]
  39. [[17 10 16 2]
  40. [ 8 19 5 5]
  41. [ 5 1 13 17]
  42. [19 12 5 12]]

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/843725
推荐阅读
相关标签
  

闽ICP备14008679号