[SciPy-User] Discrete integration with delays

josef.pktd@gmai... josef.pktd@gmai...
Thu Sep 2 20:47:06 CDT 2010


On Thu, Sep 2, 2010 at 7:02 PM, Thomas Fitzpatrick <tcf4@njit.edu> wrote:
> Can anybody help me with the following equation? It is similar to a correlation,
> but I am not sure how this done as scipy's correlation packages are compiled
> into a pyd sigtools. I would like to get an array that is the same size as the
> input.
>
> Here is the equation I am trying to code:
>
> F(T) = integration[{I(t) + I(t - T)}*E(t)*Econj(t - T)]dt from -inf to +inf
> (The code be for a discrete function)

if you multiply out the terms  integral (I(t)*E(t)) * Econj(t-T) +
integral E*(t) * (I(t-T)*Econj(t-T)) dt ,
then this looks to me like two convolutions that any of the numpy
scipy convolve should be able to handle (much faster than a python
loop).
Unless I'm interpreting something incorrectly, or the integrals are not finite.



>
>
> I tried to do it by adapting this autocorrelation function:
>
> N = len(x)
> Rxx = np.zeros(N)
>
> for m in range(N):
>    for n in range(N-m):
>        Rxx[m] = Rxx[m] + x[n]*x[n+m-1]
>
>
> Here is my attempt:
>
> f1 = np.zeros(N)
> for m in range(N):
>    for n in range(0, N - m):
>        f1[m] = f1[m] + .5*(it[n] + it[n + m])*et[n]*et[n + m]
>
> This works pretty well, but it doesn't return an array of the same size as the
> input which is an option for the scipy function 'correlate.'

padding the array with m (?) zeros might help, or padding with any
other values to continue at the end.
The convolution in ndimage have for example several options, reflect, same, ...

not sure this helps

Josef


>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list