numpy中linspace用法 (等差數列創建函數)


linspace  函數 是創建等差數列的函數, 最好是在 Matlab  語言中見到這個函數的,近期在學習Python 中的 Numpy, 發現也有這個函數,以下給出自己在學習過程中的一些總結。

 

(1)指定起始點 和 結束點。

 

默認 等差數列個數為 50。

 

 

 

(2)指定等差數列個數

 

 

 

 

(3)如果數列的元素個數指定, 可以設置 結束點  狀態。

endpoint : bool, optional

If True, stop is the last sample. Otherwise, it is not included. Default is True.

 

 

 

 

 

 

(4)如果數列的元素個數指定, 可以設置 間隔屬性 狀態

retstep : bool, optional

If True, return (samples, step), where step is the spacing between samples.

 

從上面的結果中可以看到,設置了步進差值返回的x,輸出成了元組,而元組的第二個元素為步進差值1.0。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM