numpy.linspace使用详解...
来源:互联网 发布:c语言库函数大全 chm 编辑:程序博客网 时间:2024/05/17 03:33
numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)
在指定的间隔内返回均匀间隔的数字。
返回num均匀分布的样本,在[start, stop]。
这个区间的端点可以任意的被排除在外。
start : scalar(标量)
The starting value of the sequence(序列的起始点).
stop : scalar
序列的结束点,除非endpoint被设置为False,在这种情况下, the sequence consists of all but the last of num + 1 evenly spaced samples(该序列包括所有除了最后的num+1上均匀分布的样本(感觉这样翻译有点坑)), 以致于stop被排除.当endpoint is False的时候注意步长的大小(下面有例子).
num : int, optional(可选)
生成的样本数,默认是50。必须是非负。
endpoint : bool, optional
如果是真,则一定包括stop,如果为False,一定不会有stop
retstep : bool, optional
If True, return (samples, step), where step is the spacing between samples.(看例子)
dtype : dtype, optional
The type of the output array. If dtype is not given, infer the data type from the other input arguments(推断这个输入用例从其他的输入中).
New in version 1.9.0.
samples : ndarray
There are num equally spaced samples in the closed interval [start, stop] or the half-open interval [start, stop) (depending on whether endpoint is True or False).
step : float(只有当retstep设置为真的时候才会存在)
Only returned if retstep is True
Size of spacing between samples.
See also
- arange
- Similar to linspace, but uses a step size (instead of the number of samples).
- arange使用的是步长,而不是样本的数量
- logspace
- Samples uniformly distributed in log space.
>>> np.linspace(1, 10, 10)
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
>>> np.linspace(1, 10, 10, endpoint = False)
array([ 1. , 1.9, 2.8, 3.7, 4.6, 5.5, 6.4, 7.3, 8.2, 9.1])
Out[4]: (array([ 1. , 1.9, 2.8, 3.7, 4.6, 5.5, 6.4, 7.3, 8.2, 9.1]), 0.9)
官网的例子
Examples
Graphical illustration:
谢谢原博主大佬分享。在使用matplotlib做图的时候,做横坐标的坐标轴的表示,用到了这个函数。特此记录。防止忘记,哈哈哈。
- numpy.linspace使用详解
- numpy.linspace使用详解
- numpy.linspace使用详解...
- numpy.linspace使用详解
- numpy.linspace()
- numpy学习之linspace
- numpy中linspace用法
- numpy中linspace用法
- numpy中linspace用法
- numpy函数linspace() newaxis()
- numpy模块笔记之linspace
- numpy.linspace 生成等差数组
- 均分函数 numpy.arange() 和 numpy.linspace()
- python中numpy模块中的linspace函数
- numpy之linspace函数:等差,行向量
- numpy模块的linspace函数实例
- Python numpy函数:linspace()创建等差数列
- nump.linspace使用
- Codeforces Round #438 (Div. 1 + Div. 2 combined)(除G)解题报告
- .\与..\的区别
- Java 集合系列05之 LinkedList详细介绍(源码解析)和使用示例
- 使用CEfSharp之旅(3)下载文件 弹出保存框 IDownloadHandler
- BP算法经典例题 longest increasing subsequence
- numpy.linspace使用详解...
- String、StringBuffer与StringBuilder之间区别
- 数据结构项目二:停车场管理
- IntelliJ IDEA不能访问web资源目录解决方案
- Java 集合系列06之 Vector详细介绍(源码解析)和使用示例
- 对后台返回的json数据按月份分组并求和展示
- (2)Python笔记:内建模块HTMLParser实践
- 关于 MySQL LEFT JOIN 需要了解的三点
- Ext.form.Panel表单面板各组件介绍