numpylogspace()函数
它通过使用在对数刻度上均匀分隔的数字来创建数组。
语法
numpy.logspace(start, stop, num, endpoint, base, dtype)
参数
- start:代表间隔的起始值。
- stop:它表示基准区间的停止值。
- num:范围之间的值数。
- endpoint:这是一个布尔类型值。它将stop表示的值作为间隔的最后一个值。
- base:它表示日志空间的基础。
- dtype:表示数组项的数据类型。
返回
返回指定范围内的数组。
例子1
import numpy as np arr = np.logspace(10, 20, num = 5, endpoint = True) print("The array over the given range is ",arr)
输出:
The array over the given range is [1.00000000e+10 3.16227766e+12 1.00000000e+15 3.16227766e+17 1.00000000e+20]
例子2
import numpy as np arr = np.logspace(10, 20, num = 5,base = 2, endpoint = True) print("The array over the given range is ",arr)
输出:
The array over the given range is [1.02400000e+03 5.79261875e+03 3.27680000e+04 1.85363800e+05 1.04857600e+06]
祝学习愉快! (发现内容有误?请选中要编辑的内容 -> 右键 -> 修改 -> 提交!帮助我们改进教程质量)
精选教程推荐
👇 以下精选教程可能对您有帮助,拓展您的技术视野
暂无学习笔记,成为第一个分享的人吧!
您的笔记将帮助成千上万的学习者