ubuntu下安裝numpy和matplotlib

安裝NumPy函數庫——sudo apt-get install python-numpypython

以及  sudo apt-get install python-scipyubuntu

 

NumPy函數庫的函數查看:NumPy函數數組

 

from numpy import *
random.rand(4,4)
array([[ 0.00346766,  0.31435508,  0.62660357,  0.66226196],
       [ 0.50846942,  0.36985927,  0.97623186,  0.16018687],
       [ 0.73907921,  0.47685173,  0.53514874,  0.25197389],
       [ 0.89880414,  0.07204696,  0.79321122,  0.59009984]])

 

 NumPy函數庫中存在兩種不一樣的數據類型(矩陣matrix和數組array),均可以用於處理行列表示的數字元素。bash

 

使用mat()函數能夠將數組轉化爲矩陣.I操做符實現了矩陣求逆的運算。dom

>>> randMat = mat(random.rand(4,4))
>>> randMat.I
matrix([[-2.23277822,  0.56864719,  0.72165341,  1.67388598],
        [ 1.11436389, -1.14057081, -0.0595431 ,  0.01907366],
        [ 0.03110561,  1.15558961, -0.87337803,  0.73494119],
        [ 0.84605656,  0.16058555,  1.10866379, -1.95587311]])

 

安裝matplotlib——sudo apt-get install python-matplotlib函數

相關文章
相關標籤/搜索