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函数

相关文章
相关标签/搜索