# Autocorrelation of signal with offset

If I have a stationary signal $$x(t)$$ with zero mean and with an auto correlation $$r_{xx}(\tau)$$, then what is the auto correlation of $$y(t)=x(t)+b$$ ?

My calculations so far:

\begin{align} r_{yy}(\tau) &= E\{ [x(t+\tau) + b] [x(t) + b] \} \\ &= E\{ x(t+\tau)x(t) + b x(t+\tau) + b x(t) + b^2 \} \\ &=r_{xx}(\tau) + b^2 \\ \end{align}

The problem is that the autocorrelation of a constant is a triangular pulse and not just a squared offset. What am I missing here?

• To get a triangular autocorrelation, b(t) shouldn't be a constant, but a pulse.Your math is otherwise ok – xvan May 12 '19 at 15:07
• in the time domain, adding an offset to series ( signal ) does nothing to the autocorrelation. it stays exactly the same. there are terminology differences in the frequency domain so I'm not gonna say that the same is true in the frequency domain. – mark leeds May 12 '19 at 16:11
• You are not missing anything; your calculations are perfectly correct. The triangle that you seek would occur if the equation $y(t)=x(t) + b$ holds for only for a few choices of $t$ (say, when $t$ equals $-1$ or $0$ or $+1$) and not for all $t$. With regard to the comments by @markleeds, he is using the auto-covariance function as a stand-in for what engineers call autocorrelation. Thus, his comment that adding an offset does nothing to the autocorrelation is perfectly correct as long as you understand that when he writes autocorrelation, he means what engineers call autocovariance. – Dilip Sarwate May 12 '19 at 22:32
• @Dilip Sarwate: Thanks for comment. The reason I use covariance and correlation interchangeably is because, atleast in statistics, (i.e. time domain ) correlation is just a scaled version of the covariance. So, any statements about covariance which involve expectations, are equally true for correlation. – mark leeds May 13 '19 at 0:18

I think what you're doing is using matlab or R or some other tool to find the autocorrelation numerically. In that case, you will get a triangular pulse because you're effectively doing the correlation of a noisy, short-duration pulse of height $$b$$ with itself.

In that case, the expectations in Mark's answer don't hold and you'll get a triangular pulse.

For example, if I do the following in R:

x <- rnorm(100)
acf(x+10, demean=FALSE, lag=100)
acf(x+10, demean=TRUE, lag=100)


then the first plot shows what you are suggesting (a triangular pulse) and the second plot is what Mark says (the de-meaned version).

• Hi Peter: Thanks for explaining the difference in code. The formula I use below where I subtract the second term E(X)E(Y) can be thought of as "de-meaning". My fault for not being clear on that. – mark leeds May 13 '19 at 20:50
• This is mixing up the autocorrelation function of a wide-sense-stationary process, which is a statistical entity that the OP calculated quite correctly, with the (aperiodic) autocorrelation function of a finite segment of one sample path which is a temporal calculation. Asserting equality of the two calculations gets us into ergodicity etc. And starting with discrete-time white noise as your WSS process doesn't help either. – Dilip Sarwate May 14 '19 at 2:44
• @DilipSarwate Sure! But the misguided thought that it should be a triangular pulse is probably coming from what I'm suggesting. Thanks for the -1. – Peter K. May 14 '19 at 13:12

Let me just write an answer because what I wrote above about the expectation is not correct and extremely confusing because I didn't show how the $$b^2$$ drops out.

By definition:

$$\operatorname{cov}(X, Y) \triangleq E(XY) - E(X)E(Y)$$

So, \begin{align} \operatorname{cov}\big((X_{t+\tau} + b),(X{_t} + b)\big) &= E\big((X_{t+\tau} + b)(X_{t} + b)\big) - E\big(X_{t+\tau} + b\big)\times E\big(X_{t} + b\big) \\ &= E\big(X_{t+\tau} \times X_{t}\big) + b^2 - \Big(E\big(X_{t+\tau}\big) \times E\big(X_{t}) + b^2\Big) \\ &= E\big(X_{t+\tau} \times X_{t}\big) - \Big(E\big(X_{t+\tau}\big) \times E\big(X_{t}\big)\Big) \\ &= \operatorname{cov}\big(X_{t+\tau}, X_{t}\big) \\ &= \gamma(\tau) \\ \end{align}

Apologies for confusion.

• No, the definition of covariance of $Y$ and $Y$ is $$\operatorname{cov}(X,Y) = E[(X-E[X])(Y-E[Y])]$$ where, when the righthand side is multiplied out and the linearity of expectation is used, can be re-written as $$\operatorname{cov}(X,Y) = E[XY]-E[X]E[Y].$$ In short, your whole calculation is really unnecessary. What is objectionable is your previous comment that in statistics, the autocorrelation function is just a scaled version of the autocorrelation function. Not so, not even in statistics. For a weakly stationary process, the difference. between the autocorrelation function ... – Dilip Sarwate May 14 '19 at 2:32
• (continued) .... and the autocovariance function is a positive constant which does not lend any support to your claim of scaled version which implies that one is a multiple of the other. – Dilip Sarwate May 14 '19 at 2:35
• Dilip No need to be so snarky. I'm quite certain that, in statistics, the auto-correlation is a scaled function of the autocovariance. if you don't want to believe that, feel free not to. You're a very good theory guy ( sounds like you don't do much applied-real data stuff ) but it's not necessary to cop atitiude . To anyone who reads thread, my ANSWER ( not comment. I'll delete ) is correct statistically. It is the formula for the cov of any demeaned process as Peter clearly illustrated. Note that any person with solid stat would laugh at your scaling comment. It's truly funny. – mark leeds May 14 '19 at 3:41
• Oh: and as far as I know, if you simplify an expression out using legal multiplication and addition and subtraction operations, the result is equivalent to the original expression. Let me know. – mark leeds May 14 '19 at 3:44
• Last thing to anyone who wants to understand the formula statistically. You have a series or signal or whatever you want to call it. there's an autocorrelation function associated with this series which represents how its adjacent values are related time wise. So, why would adding a constant everywhere to this series, change the previous relation between adjacent values of the series. It doesn't. The series is just lifted up or down. – mark leeds May 14 '19 at 4:12