SUM x[i] x[N-1-i] rho = ----------------- . SUM x[i]^2
An alternate interpretation is in terms of the even (symmetric) and odd (anti-symmetric) parts of a vector,
xe[i] = 0.5 (x[n] + x[N-1-i]), xo[i] = 0.5 (x[n] - x[N-1-i]).Then
SUM xe[i]^2 - SUM xo[i]^2 rho = ------------------------- . SUM xe[i]^2 + SUM xo[i]^2If the vector is symmetric (x[i] = x[N-1-i]), rho is +1. If the vector is anti-symmetric (x[i] = -x[N-1-i]), the result is -1. All other cases fall in between.
A test for near symmetry or near anti-symmetry is suggested by
SUM xo[i]^2 SUM xe[i]^2 rho = 1 - 2 ----------- = 2 ----------- - 1. SUM x[i]^2 SUM x[i]^2Declare the vector to be near-symmetric if rho >= 1 - 2 eps, where eps is the relative energy in the odd part of the vector. Similarly, declare the vector to be near-anti-symmetric if rho <= -(1 - 2 eps), where eps is the relative energy in the even part of the vector. Choosing a small value for eps, a suitable test for near symmetry or near anti-symmetry is
(int) (1./(1.-2.*eps) * rho).This returns +1 for a near symmetric vector, -1 for a near anti-symmetric vector and 0 otherwise.