The Weierstrass approximation theorem says that continuous real-valued functions on the unit interval can be uniformly approximated arbitrarily closely by polynomials. That is, for every continuous function $f:[0,1]\to\mathbb{R}$ and each $\varepsilon>0$, there is a polynomial $p$ such that $|f(x)-p(x)|<\varepsilon$ for all $x\in[0,1]$.
An elementary probabilistic proof goes as follows:
Let $U_1,U_2,\ldots$ be independent uniformly distributed random variables on $[0,1]$. For $n\in\mathbb{N}$, define a function $p_n:[0,1]\to\mathbb{R}$ by
$$p_n(x) \triangleq
\mathbb{E}\Big[\,f\Big(\frac{1_{U_1<x}+1_{U_2<x}+\cdots+1_{U_n<x}}{n}\Big)
\Big]\;,
$$
where $1_{U_i<x}$ is the indicator random variable of the event $\{U_i<x\}$. For brevity, let us write $\overline{X}_n(x)\triangleq \frac{1}{n}(1_{U_1<x}+1_{U_2<x}+\cdots+1_{U_n<x})$, so that $p_n(x)=\mathbb{E}[f(\overline{X}_n(x))]$. Note that $p_n(x)$ is a polynomial of degree $n$. Intuitively, by the law of large numbers, $\overline{X}_n(x)$ is going to be close to $x$ when $n$ is large. Hence, $f(\overline{X}_n(x))$ will also be close to $f(x)$.
To make this precise, let $\varepsilon>0$. A continuous function on a compact space is uniformly continuous and bounded. Therefore, there is a $\delta>0$ such that $|f(x)-f(y)|<\varepsilon/2$ for each $x,y\in[0,1]$ satisfying $|x-y|<\delta$. Moreover, there is a constant $c<\infty$ such that $|f(x)|<c$ for each $x\in[0,1]$.
Now, for each $x\in[0,1]$, we have
\begin{align}
|f(x)-p_n(x)| &= \Big|\mathbb{E}\big[f(x)-f(\overline{X}_n(x))\big]\Big| \\
&\leq
\mathbb{E}\big|f(x)-f(\overline{X}_n(x))\big| \\
&<
\underbrace{\mathbb{P}\big(|\overline{X}_n(x)-x|<\delta\big)}_{\leq 1}
\frac{\varepsilon}{2} +
\underbrace{\mathbb{P}\big(|\overline{X}_n(x)-x|\geq\delta\big)}_{
\text{via Chebyshev's}
}\,c \;.
\end{align}
By Chebyshev's inequality, we have
$$
\mathbb{P}\big(|\overline{X}_n(x)-x|\geq\delta\big) \leq
\frac{\mathrm{Var}[\overline{X}_n(x)]}{\delta^2} =
\frac{x(1-x)}{n\delta^2} \leq \frac{1}{4n\delta^2} \;,
$$
which is smaller than $\frac{\varepsilon}{2c}$ for $n\geq\frac{c}{2\varepsilon\delta^2}$.
It follows that $|f(x)-p_n(x)|<\varepsilon$ for all $x\in[0,1]$, provided $n\geq \frac{c}{2\varepsilon\delta^2}$, and this concludes the proof.
http://math.stackexchange.com/questions/215352/why-is-gamma-left-frac12-right-sqrt-pi/215373#215373
– Michael Hardy Dec 21 '14 at 03:11