$\int_{-\infty}^\infty \exp\{ -\frac{1}{2} (n+\frac{1}{k})(\mu-\frac{\frac{\varepsilon}{k}+\sum_{i=1}^n x_i}{n+\frac{1}{k}})^2 \} \; d\mu$ How do I integrate 
$$
\int_{-\infty}^\infty\exp\left(\vphantom{\Huge A^{A}}%
-\frac{1}{2}\left[n + {1 \over k}\right]
\left[\mu-\frac{\varepsilon/k + \sum_{i = 1}^{n}x_i}{n + 1/k}\right]^2
\right) \; d\mu$$
The answer is supposed to be $$\frac{\sqrt{2\pi}}{(n+\frac{1}{k})^{1/2}}$$
It appears this the integral is something of the form
$$\int e^{g(\mu-\frac{h}{g})^2} \; d\mu$$
How do I integrate such a thing? I tried expanding the square part but am not sure I know how to integrate it either
If I try integration by substitution, what do I substitute with? If I do 
$$u = \mu-\frac{h}{g}$$
then I still get something like
$$\int e^{gu^2} \, du$$
theres a $u^2$ ... which I dont know how to integrate
UPDATE: Background - full question from my lecture
Its actually a probability question, but the integration part in question is marked with a red arrow ... 


 A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert #1 \right\vert}%
 \newcommand{\yy}{\Longleftrightarrow}$
$\ds{%
{\cal J}_{n}
\equiv
\int_{-\infty}^\infty\exp\left(\vphantom{\Huge A^{A}}%
-\,{1 \over 2}\left[n + {1 \over k}\right]
\left[\mu - {\varepsilon/k + \sum_{i = 1}^{n}x_{i} \over n + 1/k}\right]^2
\right)\,\dd\mu}:\ {\large ?}.\qquad\qquad\dd\mu\equiv\dd x_{1}\ldots\dd x_{n}$

\begin{align}
{\cal J}_{n}
&=
\int_{-\infty}^\infty\exp\left(\vphantom{\Huge A^{A}}%
-\,{1 \over 2}\left[n + {1 \over k}\right]
\left[\mu - {\varepsilon \over nk + 1}
-
{\sum_{i = 1}^{n}x_{i} \over n + 1/k}\right]^2
\right)\,\dd\mu
\\[3mm]&
\mbox{With}\quad {x_{i} \over n + 1/k} \to x_{i},\ \mbox{we get}
\pars{~\mbox{we assume}\ n + {1 \over k} > 0~}:
\\
{\cal J}_{n}
&=
\pars{n + {1 \over k}}^{n}\int_{-\infty}^\infty\exp\left(\vphantom{\Huge A^{A}}%
-\,{1 \over 2}\left[n + {1 \over k}\right]
\left[\mu - {\varepsilon \over nk + 1}
-
\sum_{i = 1}^{n}x_{i}\right]^2
\right)\,\dd\mu
\\[3mm]&
\mbox{We make the change}\
x_{i} + {1 \over n}\pars{{\varepsilon \over nk + 1} - \mu} \to x_{i}:
\\
{\cal J}_{n}
&=
\pars{n + {1 \over k}}^{n}\int_{-\infty}^\infty\exp\left(\vphantom{\Huge A^{A}}%
-\,{1 \over 2}\left[n + {1 \over k}\right]
\left[\sum_{i = 1}^{n}x_{i}\right]^2
\right)\,\dd\mu
\\[3mm]&
\mbox{With}\ \bracks{{1 \over 2}\,\pars{n + {1 \over k}}}^{1/2}x_{i} \to x_{i}
\\
{\cal J}_{n}
&=
2^{n/2}\pars{n + {1 \over k}}^{n/2}{\cal K}_{n}
\quad\mbox{where}\quad
{\cal K}_{n}
\equiv\int_{-\infty}^\infty\exp\left(\vphantom{\Huge A^{A}}%
-\left[\sum_{i = 1}^{n}x_{i}\right]^2\right)\,\dd\mu
\end{align}

${\cal K}_{n}$ $\large\tt diverges$ since
\begin{align}
{\cal K}_{n}
&=
\int_{-\infty}^{\infty}\dd x_{1}\cdots\int_{-\infty}^{\infty}\dd x_{n - 1}
\int_{-\infty}^{\infty}\exp\pars{-\bracks{x_{n} + \sum_{i = 1}^{n - 1}x_{i}}^{2}}
\,\dd x_{n}
\\[3mm]&=
\pars{\int_{-\infty}^{\infty}\exp\pars{-x_{n}^{2}}\dd x_{n}}\
\underbrace{%
\int_{-\infty}^{\infty}\dd x_{1}\cdots\int_{-\infty}^{\infty}\dd x_{n - 1}}
_{\ds{\Large\to \infty}}
\end{align}
A: For starters, let us notice that our only integration variable is $\mu$ , and that all other symbols which appear there are independent of it, behaving like simple constants as far as the actual integration process is concerned. Thus our integral becomes $$\int_{-\infty}^\infty e^{-a(x-b)^2}dx=\int_{-\infty}^\infty e^{-at^2}dt=\frac1{\sqrt a}\int_{-\infty}^\infty e^{-u^2}du=\sqrt\frac\pi{a}$$ where a is $\frac{n+\frac1k}2$ , since we know that the value of the Gaussian integral is $\int_{-\infty}^\infty e^{-u^2}du=\sqrt\pi$.
A: The antiderivative of Exp[g (mu - h/g)^2] is
 Sqrt[Pi] Erfi[Sqrt[g] (-(h/g) + mu)] / 2 Sqrt[g]
where Erfi stands for the imaginary error function erf(iz)/i.
Integrated between - infinity and + infinity, the result is then Sqrt[Pi] / Sqrt[-g]. Replacing g by its definition in your post leads to the expected result
A: As far as I can see, your integrand looks like Exp[-a x^2]. Its antiderivative is (Sqrt[Pi] Erf[Sqrt[a] x]) / (2 Sqrt[a]). Integrated between -inifinity and + infinity, this leads to Sqrt[Pi / a]. This is exactly the answer.
