亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

numpy.linspace函數(shù)具體使用詳解

 更新時間:2019年05月27日 14:26:18   作者:螞蟻flow  
這篇文章主要介紹了numpy.linspace具體使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)

在指定的間隔內(nèi)返回均勻間隔的數(shù)字。

返回num均勻分布的樣本,在[start, stop]。

這個區(qū)間的端點可以任意的被排除在外。

Parameters(參數(shù)):

 

start : scalar(標量)

The starting value of the sequence(序列的起始點).

stop : scalar

序列的結(jié)束點,除非endpoint被設(shè)置為False,在這種情況下, the sequence consists of all but the last of num + 1 evenly spaced samples(該序列包括所有除了最后的num+1上均勻分布的樣本(感覺這樣翻譯有點坑)), 以致于stop被排除.當endpoint is False的時候注意步長的大小(下面有例子).

num : int, optional(可選)

生成的樣本數(shù),默認是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.

Returns:

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設(shè)置為真的時候才會存在)

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使用的是步長,而不是樣本的數(shù)量

logspace

Samples uniformly distributed in log space. 

當endpoint被設(shè)置為False的時候

>>> import numpy as np
>>> 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])

In [4]: np.linspace(1, 10, 10, endpoint = False, retstep= True)
Out[4]: (array([ 1. , 1.9, 2.8, 3.7, 4.6, 5.5, 6.4, 7.3, 8.2, 9.1]), 0.9)

官網(wǎng)的例子 

Examples

>>> >>> np.linspace(2.0, 3.0, num=5)
  array([ 2. , 2.25, 2.5 , 2.75, 3. ])
>>> np.linspace(2.0, 3.0, num=5, endpoint=False)
  array([ 2. , 2.2, 2.4, 2.6, 2.8])
>>> np.linspace(2.0, 3.0, num=5, retstep=True)
  (array([ 2. , 2.25, 2.5 , 2.75, 3. ]), 0.25)

Graphical illustration:

>>> >>> import matplotlib.pyplot as plt
>>> N = 8
>>> y = np.zeros(N)
>>> x1 = np.linspace(0, 10, N, endpoint=True)
>>> x2 = np.linspace(0, 10, N, endpoint=False)
>>> plt.plot(x1, y, 'o')
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.plot(x2, y + 0.5, 'o')
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.ylim([-0.5, 1])
(-0.5, 1)
>>> plt.show()

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • flask-socketio實現(xiàn)WebSocket的方法

    flask-socketio實現(xiàn)WebSocket的方法

    這篇文章主要介紹了flask-socketio實現(xiàn)WebSocket的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • python使用遞歸實現(xiàn)斐波那契數(shù)列的示例詳解

    python使用遞歸實現(xiàn)斐波那契數(shù)列的示例詳解

    這篇文章主要給大家介紹了python使用遞歸實現(xiàn)斐波那契數(shù)列的示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者使用Python具有一定的參考學習價值,需要的朋友們下面來一起來學習吧
    2024-01-01
  • python 中的@property的用法詳解

    python 中的@property的用法詳解

    這篇文章主要介紹了python @property的用法,簡單地說就是一個類里面的方法一旦被@property裝飾,就可以像調(diào)用屬性一樣地去調(diào)用這個方法,它能夠簡化調(diào)用者獲取數(shù)據(jù)的流程,感興趣的朋友跟隨小編一起看看吧
    2022-06-06
  • 淺談pytorch中的dropout的概率p

    淺談pytorch中的dropout的概率p

    這篇文章主要介紹了淺談pytorch中的dropout的概率p,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-05-05
  • 深入淺析python with語句簡介

    深入淺析python with語句簡介

    with 語句適用于對資源進行訪問的場合,確保不管使用過程中是否發(fā)生異常都會執(zhí)行必要的“清理”操作,釋放資源,這篇文章給大家介紹了python with語句簡介,感興趣的朋友一起看看吧
    2018-04-04
  • Python通過遞歸函數(shù)輸出嵌套列表元素

    Python通過遞歸函數(shù)輸出嵌套列表元素

    這篇文章主要介紹了Python通過遞歸函數(shù)輸出嵌套列表元素,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-10-10
  • Python帶你從淺入深探究Tuple(基礎(chǔ)篇)

    Python帶你從淺入深探究Tuple(基礎(chǔ)篇)

    大家都知道Python中的元組容器序列(tuple)與列表容器序列(list)有很多相同之處,他們雖然都可以存儲任意類型的數(shù)據(jù),但是一個元組定義好之后就不能夠再進行修改,對Python Tuple相關(guān)知識感興趣的朋友一起看看吧
    2021-05-05
  • python使用技巧-標準輸入

    python使用技巧-標準輸入

    這篇文章主要介紹了python使用技巧標準輸入,標準輸入即stdin ,下文圍繞python使用技巧標準輸入相關(guān)資料展開學習內(nèi)容,具有一的參考價值,需要的小伙伴可以參考一下
    2022-02-02
  • Python實現(xiàn)列表刪除重復(fù)元素的三種常用方法分析

    Python實現(xiàn)列表刪除重復(fù)元素的三種常用方法分析

    這篇文章主要介紹了Python實現(xiàn)列表刪除重復(fù)元素的三種常用方法,結(jié)合實例形式對比分析了Python針對列表元素的遍歷、判斷、轉(zhuǎn)換等相關(guān)操作技巧,需要的朋友可以參考下
    2017-11-11
  • python演示解答正則為什么是最強文本處理工具

    python演示解答正則為什么是最強文本處理工具

    正則表達式又稱規(guī)則表達式,通常被用來檢索、替換那些符合某個模式(規(guī)則)的文本,它是最強的文本處理工具,至于原因本文將給你答案
    2021-09-09

最新評論