当前位置:网站首页>numpy 随机数
numpy 随机数
2022-06-26 04:28:00 【莉莉妖_】
normal():标准正太分布样本值
numpy.random.normal(loc=0.0, scale=1.0, size=None)
loc:此概率分布的均值(对应着整个分布的中心)
scale:此概率分布的标准差(对应于分布的宽度)
size:输出的shape,默认为None,只输出一个值
import numpy
# 生成一个标准正太分布的4*4样本值
print(numpy.random.normal(size = (4,4)))
rand():[0,1)之间随机浮点数
numpy.random.rand(d0, d1, …, dn)
import numpy
# 生成一个[0,1)之间的随机浮点数或N维浮点数组 —— 均匀分布
print(numpy.random.rand()) # 生成一个随机浮点数
print(numpy.random.rand(4)) # 生成包含4个元素的一维数组
print(numpy.random.rand(2,3)) # 生成形状为2*3的二维数组
randn():随机浮点数组
numpy.random.randn(d0, d1, …, dn)
import numpy
# 生成一个浮点数或N维浮点数组 —— 正态分布
print(numpy.random.randn(10))
randint():整数或多维整数数组
numpy.random.randint(low, high=None, size=None, dtype=‘l’)
注意:dtype参数只能是int类型
import numpy
# low = 2:生成1个[0,2)之间随机整数
print(numpy.random.randint(0,2))
# low = 2,size = 5 :生成5个[0,2)之间随机整数
print(numpy.random.randint(0,2,size = 5))
# low = 2,size=(2,3):生成一个2x3整数数组,取数范围为[0,2)随机整数
print(numpy.random.randint(0,2,size = (2,3)))
边栏推荐
- The statistics in the MySQL field become strings, and then they are converted into numbers for sorting
- Thinkphp6 implements a simple lottery system
- Tencent Interviewer: How did binder get its system services?
- 钉钉开放平台-小程序开发实战(钉钉小程序客户端)
- Performance test comparison between PHP framework jsnpp and thinkphp6
- 小程序中实现视频通话及互动直播功能
- 08_ Spingboot integrated redis
- C generic
- VHDL design
- Zhubo Huangyu: you can try these non-agricultural operation skills
猜你喜欢

企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?
![[Qunhui] Internet access + custom port](/img/7d/c00caeade209a48c8f44a4fecb59d5.jpg)
[Qunhui] Internet access + custom port
![PHP design function getmaxstr to find the longest symmetric string in a string - [original]](/img/45/d8dae9e605a2f411683db7a2d40d0b.jpg)
PHP design function getmaxstr to find the longest symmetric string in a string - [original]

NPM installation tutorial

Knowledge of SQL - database design, backup and restore

Nailing open platform - applet development practice (nailing applet client)

Computer network high frequency interview questions

2020-12-18

Capture packets (Wireshark)

一幅脑图总结一下需求分析(工作上实际遇到的情况的补充)
随机推荐
[Qunhui] no port access (reverse proxy + intranet penetration)
Daily tests
Wechat applet is bound to a dynamic array to implement a custom radio box (after clicking the button, disable the button and enable other buttons)
Advanced learning of MySQL (learning from Shang Silicon Valley teacher Zhou Yang)
Notes on enterprise wechat development [original]
I like you!
Database related knowledge
Swagger
MySQL enable logbin in Qunhui docker
asp. Net web page, ASP connects to the database, and uses asp:panel and asp:dropdownlist controls
OSS CDN alicloud configuration method
CTF serialization and deserialization
Report on the "fourteenth five year plan" and future development direction of global and Chinese indoor vertical farms from 2022 to 2028
Sixtool- source code of multi-functional and all in one generation hanging assistant
08_SpingBoot 集成Redis
Clean up photo SCR virus / iframekill injection removal /iframekill removal photo scr
Report on demand situation and development trend of China's OTC industry from 2022 to 2028
Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步
Threejs special sky box materials, five kinds of sky box materials are downloaded for free
Install cenos in the virtual machine