当前位置:网站首页>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)))
边栏推荐
- [Qunhui] import certificate
- Navicat connects the pit of shardingsphere sub table and sub library plug-ins
- 钉钉开放平台-小程序开发实战(钉钉小程序服务器端)
- Knowledge of functions
- Sixtool- source code of multi-functional and all in one generation hanging assistant
- Nightmare
- WPF value conversion
- Microsoft prohibits Russian users from downloading and installing win10/11
- MySQL est livré avec l'outil de test de performance MySQL lap pour effectuer des tests de résistance
- Mobile terminal pull-down loading pull-down loading data
猜你喜欢

08_ Spingboot integrated redis

CTF serialization and deserialization

Gateway can not connect to tcp://127.0.0.1: Connection refused

钉钉开放平台-小程序开发实战(钉钉小程序客户端)

2021-02-07

企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?

Implementation of seven classes of BlockingQueue interface

Modify the number of Oracle connections

Double buffer technology asynchronous log system

Resolve PHP is not an internal or external command
随机推荐
Capture packets (Wireshark)
Group by and order by are used together
Navicat connects the pit of shardingsphere sub table and sub library plug-ins
ctf [RoarCTF 2019]easy_ calc
[Qunhui] command line acme SH automatically apply for domain name certificate
Nightmare
Mobile terminal pull-down loading pull-down loading data
CTF PHP audit bypasses filtering learning from topics
NPM installation tutorial
Svn correlation
Lua grammar explanation
Thinkphp6 implements a simple lottery system
Analysis report on development status and future trend of CMOS image sensor industry in China 2022 ~ 2028
TP5 distinct method paging problem
Understand CGI and fastcgi
What should I do if I don't understand the precious metal indicators
[Nuggets' operation routine disclosure] the routine of being truly Nuggets
Clickhouse stand alone installation
Etcd watch principle
VHDL design