np.zeros np.randint np.multiply

1.np.zeros()该函数返回一个ndarray。输出数组是具有指定形状, dtype, order并包含零的数组。

import numpy as np
a=np.zeros(6,)
a

输出

array([0., 0., 0., 0., 0., 0.])

 

2.

函数功能:
Return random integers from low (inclusive) to high (exclusive)。
Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low)。
返回最小值(包含)与最大值(不包含)之间的随机整数。
具体是:返回半开区间(前闭后开)上指定数据类型的服从离散均匀分布的随机整数。若最大值为空,默认返回[0,low)之间服从均匀分布的随机数

函数语法:

numpy.random.randint(low, high=None, size=None, dtype=int)

函数参数:
low: int or array-like of ints。Lowest (signed) integers to be drawn from the distribution (unless high=None, in which case this parameter is one above the highest such integer).
最小值:整数或整数形式的数组。分布中的最小整数值(含正负号。若high为空则,该值比分布中产生的最大值大1。

high: int or array-like of ints, optional。If provided, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None). If array-like, must contain integer values
**最大值:**可选参数,整数或整数形式的数组。若函数中给定,则比分布函数中产生的最大值大1。若为整数形式的数组,则必须包含整数值。(不理解)

size: int or tuple of ints, optional。Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.
**大小:**可选参数,整数或者整数元组,若以(m,n,k)的形式给定大小则从分布函数中产生m ∗ n ∗ k m*n*kmnk个样本值。默认为空,此时返回单个样本值。

dtype: dtype, optional。Desired dtype of the result. Byteorder must be native. The default value is int.
数据类型: 可选参数,所需要的结果数据类型,默认整数型。

 

3.print ('两个数组相乘:') print (np.multiply(a,b)).     https://www.runoob.com/numpy/numpy-arithmetic-operations.html

第一个数组:
[[0. 1. 2.]
 [3. 4. 5.]
 [6. 7. 8.]]


第二个数组:
[10 10 10]


两个数组相乘:
[[ 0. 10. 20.]
 [30. 40. 50.]
 [60. 70. 80.]]



posted @   Tomorrow1126  阅读(153)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
历史上的今天:
2020-03-16 bmp图像反色的原理及实现
2020-03-16 RGBQUAD数据结构
2020-03-16 位图信息头和位图文件头
2020-03-16 图像类型分类
点击右上角即可分享
微信分享提示