numpy - logspace()函数

numpy - logspace()函数 首页 / Numpy入门教程 / numpy - logspace()函数

它通过使用在对数刻度上均匀分隔的数字来创建数组。

语法

numpy.logspace(start, stop, num, endpoint, base, dtype)

参数

它接受以下参数。

  1. start:代表间隔的起始值。
  2. stop:它表示基准区间的停止值。
  3. num:范围之间的值数。
  4. endpoint:这是一个布尔类型值。它将stop表示的值作为间隔的最后一个值。
  5. base:它表示日志空间的基础。
  6. 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]

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入剖析Kubernetes -〔张磊〕

白话法律42讲 -〔周甲徳〕

.NET Core开发实战 -〔肖伟宇〕

Flink核心技术与实战 -〔张利兵〕

大厂晋升指南 -〔李运华〕

Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕

大型Android系统重构实战 -〔黄俊彬〕

结构会议力 -〔李忠秋〕

结构沟通力 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)