Cross-correlation seems defined backwards Suppose $f$ and $g$ are real. Why
$$
C(\tau)=(f\star g)(\tau) = \int_{-\infty}^{\infty} f(t) g(t + \tau)dt \tag{1}
$$
and not
$$
C(\tau)=(f\star g)(\tau) = \int_{-\infty}^{\infty} f(t) g(t - \tau)dt\tag{2}
$$
where $f=$ input, $g =$ template/pattern to be matched. $(2)$ properties:

*

*If $g$ is centered at $t=0$, and $f$ is $g$ shifted to $T$, then $C$ peaks at $T$.


*If $g$ is centered at $t=T_0$, and $f$ is $g$ shifted to $T_1$, then $C$ peaks at $T_1 - T_0$.

*

*Suppose $f$ is $g$ shifted to $t=0$. Then, $C$ peaks at $-T_0$, meaning $g$ is most similar to $f$ when shifted left by $T_0$.



$(1)$ has all of this backwards. $C$ at $1$ is similarity of $g$ with $f$ at $-1$, i.e. inner product of $f$ with $g$ shifted to $-1$.
How is this useful? Why not just have $C(1)$ mean "similarity of input with template shifted by $1$", which for template centered at 0 is nicely "template centered at $1$", e.g.

$C$ peaks at (1cm, 2cm) because that's where the apple is in the image

Yes, $(1)$ becomes $(2)$ if we look at it as matching input against template instead, but this answers the reverse of "where at input does this sub-pattern occur". I can also see it as answering "after how long will input match template if we pass it through the template (e.g. signal into system)", but we won't ask this for images and it's more suited as a physics than statistical tool.
Whatever the case, does $(2)$ have a name?

If the interpretation of $\tau$ is correlation lag , then use the form of equation given by (1). Which is,
$$C(\tau)=(f\star g)(\tau) = \int_{-\infty}^{\infty} f^*(t) g(t + \tau)dt $$
Details in this answer
