Determine numerically centrum of symmetry of sampled function

17 Views Asked by At

I have a samped function $f$ represented as a vector f of length N, which shall be approximately even/symmetric with respect to particular unknown index I $$I \in [0 \ldots N-1]$$ so that

f[I+i]-f[I-i] \approx 0 with respect to admissible i's

I know I shall be somewhere around the center of x axis e.g. $N/2 \pm 0.1N$ . The problem is my sampled f contains noise and may be biased towards the tails.

In the following graph I plot one realization of f and its flipped version Approximatelly symmetric function

The best I did so far is trying to iteratively sum f with its flipped shifted version and find the minimum

import numpy as np
ff = -np.flip(f)
IND = np.arange(-100,100)
J = IND[np.argmin([np.linalg.norm(f+ np.roll(ff,i)) for i in IND])]
print("Minimum is at shift I = %f."%(N/2 - J/2))

I can not rely on argmax as there don't need to be the peak. I would like to find $I$ that is resistant to the noise in tails and more sensitive to the center of the f.

There might be some discrete FFT based methods, but I did not managed to get one working. What are your suggestions to address this problem?