Python programming, with examples in hydraulic engineering and in hydrology.
Showing posts with label logarithmic. Show all posts
Showing posts with label logarithmic. Show all posts
Sunday, April 21, 2019
Logarithmic and Exponential Curve Fit in Python - Numpy
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]
Labels:
curve fit,
exponential,
fit,
logarithmic,
numpy,
polyfit,
regression
Subscribe to:
Posts (Atom)