File size: 331 Bytes
bd39f54
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import numpy as np
import matplotlib.pyplot as plt


def poly_fit(x_values, y_values, degree=60):
    # 使用 numpy 的 polyfit 函数进行多项式拟合
    coefficients = np.polyfit(x_values, y_values, degree)

    # 生成拟合的多项式函数
    fitted_curve = np.poly1d(coefficients)

    return fitted_curve(x_values)