linspace 函數(shù) 是創(chuàng)建等差數(shù)列的函數(shù), 最好是在 Matlab 語言中見到這個(gè)函數(shù)的,近期在學(xué)習(xí)Python 中的 Numpy, 發(fā)現(xiàn)也有這個(gè)函數(shù),以下給出自己在學(xué)習(xí)過程中的一些總結(jié)。
(1)指定起始點(diǎn) 和 結(jié)束點(diǎn)。
默認(rèn) 等差數(shù)列個(gè)數(shù)為 50。
(2)指定等差數(shù)列個(gè)數(shù)
(3)如果數(shù)列的元素個(gè)數(shù)指定, 可以設(shè)置 結(jié)束點(diǎn) 狀態(tài)。
endpoint : bool, optional
If True, stop is the last sample. Otherwise, it is not included. Default is True.
(4)如果數(shù)列的元素個(gè)數(shù)指定, 可以設(shè)置 間隔屬性 狀態(tài)。
retstep : bool, optional
If True, return (samples, step), where step is the spacing between samples.
從上面的結(jié)果中可以看到,設(shè)置了步進(jìn)差值返回的x,輸出成了元組,而元組的第二個(gè)元素為步進(jìn)差值1.0。
以上這篇淺談numpy中l(wèi)inspace的用法 (等差數(shù)列創(chuàng)建函數(shù))就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持服務(wù)器之家。