3

As I understand it, from Robert Israel's answer here, if $X, Y, Z$ are i.i.d. with uniform distribution on the interval $[0,1]$, then $T = X+Y+Z$ has the piecewise PDF given in the link.

How did he find this? How would I go about finding the PDF for any $X_1, X_2, \dots X_n$ that are i.i.d. with uniform distribution on the interval $[0,1]$? Where should I look for literature on the subject?

martin
  • 8,998

1 Answers1

4

Theorem: Let $X$ and $Y$ be two independent random variables with pdf $f_X(x)$ and $f_Y(y)$ then the sum $Z = X+Y$ is a random variable with pdf $$f_Z(z) = (f_X * f_Y)(z) \equiv \int_{-\infty}^\infty f_X(z-y)f_Y(y)\,{\rm d}y$$

For a reference see e.g. Theorem 7.1 here.

If $f_n$ is the pdf of the sum $S_n = X_1 + X_2 + \ldots + X_n$ and $X_i$ are i.i.d. random variables with uniform distribution on $[0,1]$ then the theorem above gives us

$$f_{n}(z) = \int_0^1 f_{n-1}(z-y)\,{\rm d}y = \int_{z-1}^{z} f_{n-1}(t)\,{\rm d}t$$

so we can compute the pdf of $S_n$ recursively (see the end of the answer for a simple algorithm).


For $n=2$ we find

$$f_{X+Y}(z) = \int_{z-1}^{z} f_X(t)\,{\rm d}t = \cases{z&$0 \le z\le 1$\cr 2-z&$1 \le z\leq 2$\cr 0& otherwise}$$

${\bf\text{Explanation}}$: The integrand $f_{X}(t)$ is zero if $t \not \in [0,1]$ and one otherwise so if $0<z<1$ the integral is simply $\int_0^{z}{\rm d}z = z$ and if $1<z<2$ then the integral is $\int_{z-1}^1{\rm d}z = 2-z$.

For $n=3$ we find:

$$f_{X+Y+Z}(z) = \int_{z-1}^z f_{X+Y}(t)\,{\rm d}t = \cases{ \frac{z^2}{2}&$0 \le z\le 1$\cr -\frac 3 2- {z}^{2}+3\,z&$1 \le z\le 2$\cr \frac 92-3\,z+\frac{z^2}{2}&$2 \le z\leq 3$\cr 0& otherwise}$$

${\bf\text{Explanation}}$: The integrand $f_{X+Y}(t)$ is zero if $t\not\in[0,2]$ so if $0<z<1$ the integral becomes $\int_0^z z\,{\rm d}z = \frac{z^2}{2}$. If $1<z<2$ the integral becomes $\int_{z-1}^{1}z\,{\rm d}z + \int_{1}^{z}(2-z)\,{\rm d}z = -\frac{3}{2} - z^2 + 3z$. Since the pdf is symmetric about the midpoint $z=\frac 32$ the pdf becomes $\frac{(3-z)^2}{2} = \frac{9}{2} - 3z + \frac{z^2}{2}$ if $2<z<3$.


Here is a simple algorithm for evaluating the integrals in general. If we have derived that

$$f_{n}(z) = \cases{ g_{1,n}(z) & $0 \le z\le 1$ \cr g_{2,n}(z) & $1 \le z\le 2$ \cr \ldots & $\ldots$}$$

then we get the following recurrence for $g_{k,n+1}(z)$: $$g_{1,n+1}(z) = \int_0^z g_{1,n}(z)\,{\rm d}z$$ and $$g_{k,n+1}(z) = \int_{z-1}^{k-1} g_{k-1,n}(z)\,{\rm d}z + \int_{k-1}^z g_{k,n}(z)\,{\rm d}z~~~~~\text{for}~~~~ k=2,3,\ldots, \lfloor n/2\rfloor$$

and the remaining functions can be found by using the symmetry of $f_{n+1}(z)$ about $z=\frac{n+1}{2}$ so $g_{k,n+1}(z) = g_{n+1-k,n+1}(n+1-z)$.

Here is an implementation of this in Mathematica:

n = 4;
ffunc = Table[If[i == 1, 1, 0], {i, 1, n}];
Do[
  temp = ffunc;

  temp[[1]] = Integrate[ffunc[[1]], {z, 0, z}];
  Do[temp[[k]] = Integrate[ffunc[[k - 1]], {z, z - 1, k-1}] + Integrate[ffunc[[k]], {z, k-1, z}];
   , {k, 2, Floor[(i + 1)/2]}];
  Do[temp[[k]] = temp[[i - k + 1]] /. z -> i - z;, {k, Floor[(i + 1)/2] + 1, i}];

  ffunc = temp;
  , {i, 2, n}];
ExpandAll[ffunc] // MatrixForm
Winther
  • 24,478
  • 1
    @martin I added some notes on a simple algorithm + an implementation of it in Mathematica. – Winther Nov 03 '15 at 22:53
  • thank you - this is great - deserves far more upvotes!! ;) – martin Nov 03 '15 at 22:57
  • that MMA algorithm is fast! – martin Nov 03 '15 at 23:37
  • 1
    @martin It's just integration of polyomials involved which is not hard to do for MA. btw there was a typo in the first version which gave wrong results for $n\geq 5$ which is corrected now. – Winther Nov 03 '15 at 23:40
  • please feel free to post MMA answer here – martin Nov 04 '15 at 00:33
  • 1
    @martin I'll pass (my Mathematica skillz is not much to write home about so I'm sure it can be done much better), but feel free to post it yourself if you want to. – Winther Nov 04 '15 at 00:40
  • 1
    For comparison purposes: BSplineBasis[n - 1, x/n] // PiecewiseExpand // Simplify. It's amusing how a function from a distant field can represent the solution... – J. M. ain't a mathematician Nov 04 '15 at 00:51
  • @J.M. Yes. I just saw (and upvoted) your solution. That is the fastest Mathematica implementation for sure. I just have to figure out what BSplineBasis really is:) Do you have any useful links? – Winther Nov 04 '15 at 00:54
  • Well, looking at the convolution-based recursive definition, I suddenly recalled that one way to start B-spline theory is to consider them as repeated convolutions of a boxcar function. Here are two references, among others. – J. M. ain't a mathematician Nov 04 '15 at 02:38
  • @J.M. I see, that explains the connection then. Thank you for the refs! – Winther Nov 04 '15 at 02:43