numpy模块的linspace函数实例

来源:互联网 发布:抽奖软件代码 编辑:程序博客网 时间:2024/05/16 19:35
#coding=utf8'''linspace函数进行采样linspace(start, stop, num, endpoint, retstep, dtype)start:开始值stop:终值num:元素个数,默认值50。可选参数endpoint : 如果是为 True,包括终值stop。默认值为 True。可选参数retstep : 如果为True,返回 (`samples`, `step`),step表示 samples之间的间距。可选参数dtype :  输出数组的数据类型.。如果 `dtype` 没有给定,参照其他输入的数据类型。可选参数'''import numpy as nplinspace1=np.linspace(1,20)print "The default :",linspace1linspace2=np.linspace(1,20,10)print "The num=10 :",linspace2linspace3=np.linspace(1,20,10,False)print "The endpoint=False:",linspace3linspace4=np.linspace(1,20,10,False,True)print "The retstep=True:",linspace4linspace4=np.linspace(1,20,10,False,True,int)print "The dtype=int:",linspace4

原创粉丝点击