Suppose a customer arrival to a gas station follows a non-stationary Poisson process with the following arrival rate per hour:
[6am - 9am] has $\lambda = 20$.
[9am - 3pm] has $\lambda = 8$.
[3pm - 7pm] has $\lambda = 12$.
[7pm - 10pm] has $\lambda = 6$.
Compute the variance of total number of customers that arrive in a single day.
My attempt Let $X = $ total number of customers that arrive in a single day. Then $Var(X) = E(X^2)- [E(X)]^2 = (20^2\times 3+8^2\times 6+12^2\times 4 + 6^2\times 3) - (20\times 3+8\times 6+12\times 4 + 6\times 3)^2 = 2268-174^2 = -28008$
However, this number is negative, so it does not make sense in the context of this problem. But I could not see why it's wrong though, considering the way to compute $E(X)$ is actually correct. Could someone please point out the mistake for $E(X^2)$?
Two key points:
A Poisson distribution with parameter $\lambda$ (i.e. its mean and variance) has $E(X^2)=\lambda+\lambda^2$: this is the error in your calculation as you were using $E(X^2)=\lambda^2$
The sum of two independent Poisson distributions with parameters $\lambda$ and $\mu$ is another Poisson distribution with parameter $\lambda+\mu$
So you have $16$ independent Poisson distributions and their sum is another Poisson distribution with parameter $20\times 3+8\times 6+12\times 4 + 6\times 3 =174$. This is therefore the variance of the sum as well as being its mean.