On 19/07/2020 11:19, Dino wrote:
> 
> Hi, I am looking at someone else's code trying to understand their use
> of numpy.polyfit.
> 
> My understanding was that you can use it to fit polynomials, but
> apparently, the original author has used it for logarithmic and
> exponential curves as well this way:
> 
> Logarithmic
> 
>     def fit_model(self):
>         self.coefficients = np.polyfit(np.log(self.x), self.y, 1)
> 
> Exponential
> 
>     def fit_model(self):
>         self.coefficients = np.polyfit(self.x, np.log(self.y), 1)
> 
> is this an ok use of np.polyfit? Will it yield the expected result.
> 
> Thanks

It depends on what you expect the result to be. There's nothing
inherently wrong with transforming variables before using least squares
fitting. Whether it gives you the "best" estimates for the coefficients
is a different issue.

Duncan
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to