我对 Python 比较陌生,正在尝试实现 Gauss-Newton 方法,特别是 Wikipedia 页面上的示例(Gauss-Newton algorithm,3 示例)。以下是我到目前为止所做的:
import scipy
import numpy as np
import math
import scipy.misc
from matplotlib import pyplot as plt, cm, colors
S = [0.038,0.194,.425,.626,1.253,2.500,3.740]
rate = [0.050,0.127,0.094,0.2122,0.2729,0.2665,0.3317]
iterations = 5
rows = 7
cols = 2
B = np.matrix([[.9],[.2]]) # original guess for B
Jf = np.zeros((rows,cols)) # Jacobian matrix from r
r = np.zeros((rows,1)) #r equations
def model(Vmax, Km, Sval):
return ((vmax * Sval) / (Km + Sval))
def partialDerB1(B2,xi):
return …Run Code Online (Sandbox Code Playgroud)