# How can a sum of squared random variables distributed normally with mean $\mu$ and variance $\sigma^2$ be represented as a gamma distribution?

Firstly, I'm sorry about the formatting, I hope someone can come along and give me a hand with this.

I have a sum of squares of $$n$$ random variables distributed normally with mean $$\mu$$ and variance $$\sigma^2$$: $$\mathcal{N}(\mu, \sigma^2)$$. I know that this sum can be represented as a gamma distribution, but I can't seem to work it out. What is this sum's corresponding gamma format? Ideally, I want to use the shape and scale format for the gamma distribution.

• Did you have a look at en.wikipedia.org/wiki/…? – Vimal Nov 8 '18 at 14:57
• @Vimal yeah I did, but I don’t have a standard normal, and I just had some trouble. I’m not a pro. – Dan White Nov 8 '18 at 15:25
• Perhaps start with $X_i \sim N(\mu_i, \sigma^2=1)$ and express the sum as a non-central chi-squared distribution with $n$ degrees of freedom and non-centrality parameter $\lambda = \sum_i \mu_i^2.$ Then for general $\sigma,$ express $\sum_i X_i^2$ as an appropriate multiple of a non-central chi-squared distribution. – BruceET Nov 8 '18 at 15:40
• Your question is answered en passant at stats.stackexchange.com/questions/116334/…. It's a Gamma distribution if and only if $\mu=0.$ – whuber Nov 8 '18 at 15:50

Comment (continued): As a particular example using R, let $$X_1 \sim \mathsf{Norm}(\mu = 1, \sigma = 1),$$ $$X_2 \sim \mathsf{Norm}(\mu = 2, \sigma = 1),$$ and $$X_3 \sim \mathsf{Norm}(\mu = 3, \sigma = 1).$$ Then $$Q = \sum_{i=1}^3 X_i^2\sim \mathsf{Chisq}(\nu = 3, \lambda=14).$$

Demonstration using simulation:

set.seed(1108);  m = 10^6
mu = c(1,2,3)                       # mean vector recycles
x = rnorm(m*3, mu, 1)
MAT = matrix(x, nrow=m, byrow=T)    # m x 3 matrix
q = rowSums(MAT^2)
mean(q)
[1] 17.00669                        # aprx df + ncp = 17

hist(q, prob=T, col="skyblue2", main="Simulated CHISQ(df=3,ncp=14)")
curve(dchisq(x, 3, ncp=14), add=T, lwd=2, col="red")


See R documentation of dchisq for details of the R function and Wikipedia for the PDF and moments of the non-central chi-squared distribution. I will leave it to you to handle the constant multiple in case the normal distributions have the same variance $$\sigma^2.$$ [If the normal distributions have different variances, then it may be best to think in terms of $$\sum_i \frac{(X_i-\mu_i)^2}{\sigma_i} \sim \mathsf{Chisq(n)}.]$$