用python做作业笔记

import numpy as np
import matplotlib.pyplot as plt
import numpy.linalg as la

矩阵操作

求逆

A_inv = A.I

求范数

ans = la.norm(A)
ans1 = la.norm(A, 1)
ans2 = la.norm(A, 2)

拟合

拟合函数

def f_1(x, A, B):  
    return A*x + B 

拟合

 k, b = optimize.curve_fit(f_1, X, Y)[0]  

画图

直方图

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import mlab
from matplotlib import rcParams
fig1 = plt.figure(2)
rects =plt.bar(left = (0.2,1),height = (1,0.5),width = 0.2,align="center",yerr=0.000001)

你可能感兴趣的:(笔记)