当前位置:网站首页>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)))
边栏推荐
- Construction of art NFT trading platform | NFT mall
- The select option in laravel admin contains a large amount of data
- Laravel file stream download file
- CTF serialization and deserialization
- What are the advantages and risks of paper gold investment
- PHP inherited in class return does not work
- PIP batch complete uninstall package
- Sixtool- source code of multi-functional and all in one generation hanging assistant
- CTF crypto (I) some simple encoding and encryption
- SQL related knowledge - DDL
猜你喜欢

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)

TP5 distinct method paging problem

Implementation of seven classes of BlockingQueue interface
![[Qunhui] Internet access + custom port](/img/7d/c00caeade209a48c8f44a4fecb59d5.jpg)
[Qunhui] Internet access + custom port

Group by and order by are used together
![[Qunhui] no port access (reverse proxy + intranet penetration)](/img/bc/b1e0c5c382e30fbcea28fbc68c1151.jpg)
[Qunhui] no port access (reverse proxy + intranet penetration)

Parse JSON interface and insert it into the database in batch

Nailing open platform - applet development practice (nailing applet server side)
随机推荐
Tp6 multi table Association (table a is associated with table B, table B is associated with table C, and table d)
Mobile terminal pull-down loading pull-down loading data
2021/11/6-burpsuit packet capturing and web page source code modification
Knowledge of functions
Threejs special sky box materials, five kinds of sky box materials are downloaded for free
Ipvs0 network card of IPVS
SQL related knowledge - constraints
win10 系统打开的软件太小,如何变大(亲测有效)
What are the advantages and risks of paper gold investment
PHP installation SSH2 extension
Mysql8.0 configuring my SQL in INI file_ mode=NO_ AUTO_ CREATE_ User can start
钉钉开放平台-小程序开发实战(钉钉小程序客户端)
Report on operation mode and future development trend of China's refining and chemical market 2022-2028
Daily tests
Redis cache message queue
Go SQL parsing time Time type
Analysis report on development status and future trend of CMOS image sensor industry in China 2022 ~ 2028
PHP has the problem of using strtotime to obtain time in months and months [original]
Resolve PHP is not an internal or external command
Zhubo Huangyu: you can try these non-agricultural operation skills