[SciPy-User] estimation problem

Neal Becker ndbecker2 at gmail.com
Fri Jul 15 14:12:40 EDT 2011


josef.pktd at gmail.com wrote:

> 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
> 

What I tried that seems to work is:

def func (x, k):
  return complex_to_real (complex_func (real_to_complex (x * k)))

popt, pcov = curve_fit (func, complex_to_real(x), complex_to_real (y))

where complex_to_real: interpret a complex vector as alternating real/imag parts
real_to_complex: interpret alternating entries in float vector as real/imag 
parts of complex

Does this seem like a valid use of curve_fit?





More information about the SciPy-User mailing list