With
numpy function "polyfit":
X,y : data to be fitted
import numpy as np
1. Exponential fit
cf = np.polyfit(X, np.log(y), 1)
will return two coefficients, who will compose the equation:
exp(cf[1])*exp(cf[0]*X)
2. Logarithm fit:
cf = np.polyfit(np.log(X), y, 1)
will return two coefficients, who will compose the equation:
cf[0]*log(X)+cf[1]
No comments:
Post a Comment