ubuntu下安装numpy和matplotlib

安装NumPy函数库——sudo apt-get install python-numpy

以及  sudo apt-get install python-scipy

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),都可以用于处理行列表示的数字元素。

使用mat()函数可以将数组转化为矩阵.I操作符实现了矩阵求逆的运算。

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

原文地址:https://www.cnblogs.com/tonglin0325/p/6044980.html