[SciPy-User] estimation problem

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Jul 15 14:04:39 EDT 2011


On Fri, Jul 15, 2011 at 1:39 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
> josef.pktd at gmail.com wrote:
>
>> On Fri, Jul 15, 2011 at 12:58 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
>>> I have a known signal (vector) 'x'.  I recieve a vector 'y'
>>>
>>> y = F(k x) + n
>>>
>>> where n is Gaussian noise, and k is an unknown gain parameter.
>>>
>>> I want to estimate k.
>>>
>>> F is a known function (nonlinear, memoryless).
>>>
>>> What might be a good approach to try?  I'd like this to be an 'online'
>>> approach - that is, I provide batches of training vectors (x, n), and the
>>> estimator will improve the estimate (hopefully) as more data is supplied.
>>
>> scipy.optimize.curve_fit
>>
>> I would reestimate with the entire sample after a batch arrives using
>> the old estimate as a starting value.
>>
>> There might be shortcuts reusing and updating the Jacobian and
>> Hessian, but I don't know of anything that could be used directly. (I
>> don't have much idea about non-linear kalman filters and whether they
>> would help in this case.)
>>
> In my case, x, y, n are complex.  I guess I need to handle that myself
> (somehow).

I guess curve_fit won't help then.
optimize.leastsq should still work if the function returns a 1d array
abs(y-F(x)) so that (abs(y-F(x))**2).sum() is the real loss function.

If k is also complex, then I would think that it will have to be
separated into real and complex parts as separate parameters.

If you need the extra results, like covariance matrix of the estimate,
then I would just copy the parts from curve_fit.

(I don't think I have seen complex Gaussian noise, n, before.)

Josef


>
> Traceback (most recent call last):
>  File "test_curvefit.py", line 378, in <module>
>    run_line (sys.argv)
>  File "test_curvefit.py", line 375, in run_line
>    result = run (opt, cmdline)
>  File "test_curvefit.py", line 244, in run
>    popt, pcov = curve_fit (func, rcv_in[SPS*SI:SPS*SI+2*N],
> mod_out[SPS*SI:SPS*SI+2*N])
>  File "/usr/lib64/python2.7/site-packages/scipy/optimize/minpack.py", line 426,
> in curve_fit
>    res = leastsq(func, p0, args=args, full_output=1, **kw)
>  File "/usr/lib64/python2.7/site-packages/scipy/optimize/minpack.py", line 283,
> in leastsq
>    gtol, maxfev, epsfcn, factor, diag)
> minpack.error: Result from function call is not a proper array of floats.
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list