Re: Use non-linear least squares to fit a function

2022-09-20 Thread Yaqiang Wang
I found the solution to calculate partial gradients of the parameters unsing FiniteDifferencesDifferentiator and DerivativeStructure: https://github.com/meteoinfo/MeteoInfo/blob/master/meteoinfo-math/src/main/java/org/meteoinfo/math/optimize/MyParametricUnivariateFunction.java. A test case was

Re: Use non-linear least squares to fit a function

2022-09-20 Thread Yaqiang Wang
Unfortunately, I can not figure out how to calculate partial gradients using DerivativeStructure, so I used a simple way to calculate the gradients of the parameters (

Re: Use non-linear least squares to fit a function

2022-08-02 Thread Gilles Sadowski
Hello. Le mar. 2 août 2022 à 10:42, Yaqiang Wang a écrit : > > Gilles, > > What I gather from the documentation is that the intended purpose is > > to track the values of some function and all its derivatives when the > > function is defined programmatically (using the usual arithmetical > >

Re: Use non-linear least squares to fit a function

2022-08-02 Thread Yaqiang Wang
Gilles, What I gather from the documentation is that the intended purpose is > to track the values of some function and all its derivatives when the > function is defined programmatically (using the usual arithmetical > operators, and generalizations of the functions defined in the "Math" > JDK

Re: Use non-linear least squares to fit a function

2022-08-01 Thread Gilles Sadowski
Hello. Le lun. 1 août 2022 à 16:03, Yaqiang Wang a écrit : > > Gilles, > > Thanks so much for your patiently response! I know I can write a gradient > method for a specific function, but my purpose is to make the gradient > method suitable for any function of yi = f(xi, p1, p2, p3, ...). That

Re: Use non-linear least squares to fit a function

2022-08-01 Thread Yaqiang Wang
Gilles, Thanks so much for your patiently response! I know I can write a gradient method for a specific function, but my purpose is to make the gradient method suitable for any function of yi = f(xi, p1, p2, p3, ...). That means the users don't need to override a new fixed gradient method for a

Re: Use non-linear least squares to fit a function

2022-08-01 Thread Gilles Sadowski
Hi. Le dim. 31 juil. 2022 à 18:05, Yaqiang Wang a écrit : > > Currently I just want to fit univariate function such as the following Python > function: > > def func(x, a, b, c): > return a * exp(-b * x) + c > > > I also tried using SimpleCurveFitter to do it. MyParametricUnivariateFunction

Re: Use non-linear least squares to fit a function

2022-07-31 Thread Gilles Sadowski
Hi. Le dim. 31 juil. 2022 à 18:05, Yaqiang Wang a écrit : > > Currently I just want to fit univariate function such as the following Python > function: > > def func(x, a, b, c): > return a * exp(-b * x) + c > > > I also tried using SimpleCurveFitter to do it. MyParametricUnivariateFunction

Re: Use non-linear least squares to fit a function

2022-07-31 Thread Yaqiang Wang
Currently I just want to fit univariate function such as the following Python function: def func(x, a, b, c): return a * exp(-b * x) + c I also tried using SimpleCurveFitter to do it. MyParametricUnivariateFunction implements ParametricUnivariateFunction and overrides value and gradient

Re: Use non-linear least squares to fit a function

2022-07-31 Thread Gilles Sadowski
Le dim. 31 juil. 2022 à 03:46, Yaqiang Wang a écrit : > > Gilles, > > Thanks for your reply! Concretely to the point, I want to implement SciPy > curve_fit function using Java and Jython through Apache commons math > library. Any idea of it? I guess that your function is multivariate (?);

Re: Use non-linear least squares to fit a function

2022-07-30 Thread Yaqiang Wang
Gilles, Thanks for your reply! Concretely to the point, I want to implement SciPy curve_fit function using Java and Jython through Apache commons math library. Any idea of it? Regards Yaqiang On Sat, Jul 30, 2022 at 11:17 PM Gilles Sadowski wrote: > Hello. > > Le sam. 30 juil. 2022 à 10:58,

Re: Use non-linear least squares to fit a function

2022-07-30 Thread Gilles Sadowski
Hello. Le sam. 30 juil. 2022 à 10:58, Yaqiang Wang a écrit : > > I know implementing the ParametricUnivariateFunction > > interface > and overriding value and gradient

Re: Use non-linear least squares to fit a function

2022-07-30 Thread Yaqiang Wang
I forgot to add the linkage of getJacobianFunction ( https://github.com/meteoinfo/MeteoInfo/blob/master/meteoinfo-math/src/main/java/org/meteoinfo/math/optimize/OptimizeUtil.java ). Regards Yaqiang On Sat, Jul 30, 2022 at 4:58 PM Yaqiang Wang wrote: > I know implementing the

Use non-linear least squares to fit a function

2022-07-30 Thread Yaqiang Wang
I know implementing the ParametricUnivariateFunction interface and overriding value and gradient methods can fit the custom curve function. But the gradient array has to be