Week 5 - Curve fitting
1. Ans: popt : array Optimal values for the parameters so that the sum of the squared residuals of f (xdata, *popt) - ydata is minimized
pcov : 2d array The estimated covariance of popt. The diagonals provide the variance of the parameter estimate.
2. Ans: NumPy converts the list into a ndarray to perform mathematical functions.
3. Ans: *popt returns the coefficients stored in popt array calculated using curve_fit
4,5,6 Ans:
Objective: To perform curve-fitting on given temperature and cp data using python.
Curve_fitting: is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to constraints. Curve fitting can involve either interpolation, where an exact fit to the data is required, or smoothing, in which a "smooth" function is constructed that approximately fits the data.
How do make a curve fit perfectly?
- A perfect Curve fit refers to that curve that mathematically represents the original data set, independent of the degree of a polynomial equation.
- A perfect Curve fit takes into consideration most of the points in the data set, and the perfectness of the fit depends on the minimization of the error.
How to get the Best fit?
- the best fit Comes with no error/zero error after considering the values of the entire dataset
- The best fit line can be calculated by minimizing the distance between the actual and predicted output. There are several methods to do this like sum of squared errors, the sum of absolute errors, root mean squared error, etc.
- The difference between the predicted output and the actual output should be the least.
Conclusion:
After observing the above graphs, linear and quadratic curves are not the best fit for the actual data curve.
A cubic curve provides a better fit but is not as smooth as a bi-quadratic. As the degree of the polynomial was raised the curve is getting better and smooth and R-square is too getting closer to 1 as expected but this provides multiple answers and doesn't end up with where to stop the fit. In such cases the lower the degree of a polynomial with better smoothness. In this case, the Bi-quadratic equation gives a better fit.