# Compute cumulative distribution using triangular kernel function

Suppose that we use the kernel density estimate

${\hat{f}}_h\left(x\right)=\frac{1}{nh}\sum_{i=1}^nK\left(\frac{x-X_i}{h}\right)$

With the kernel function $K\left(u\right)=\left(1-\left\vert{}u\right\vert{}\right)I\left(\left\vert{}u\right\vert{}\leq{}1\right)$and bandwidth h to estimate the probability density function f(x). Since the cumulative distribution function, $F\left(x\right)=\int_{-\infty{}}^xf\left(u\right)du$

F(x) can be estimated by ${\hat{F}}_h\left(x\right)=\int_{-\infty{}}^x{\hat{f}}_h\left(u\right)du$

Compute ${\hat{F}}_h\left(x\right)$

I tried to substitute all the information I have into the overall equation but I am having trouble integrating both the absolute and indicator function.

• Please explain what you mean by "computing" $\hat F_h(x)$. Exactly what data or inputs would you begin with and what output do you expect? Although you refer to "all the information I have," you don't appear to have told us anything about it. – whuber Mar 1 '16 at 19:33
• @whuber Sorry if I wasn't clear. That was the full question given to me without any data. So the answer is supposed to be a general formula. – Stongals Mar 2 '16 at 3:23

Please check, I am tired :

$\hat{F}_h(x)=\int_{-\infty}^{x}\frac{1}{nh}\sum_{i=1}^{n}K(\frac{u−X_i}{h})du$

$=\frac{1}{nh}\sum_{i=1}^{n}\int_{-\infty}^{x}(1-|\frac{u−X_i}{h}|)\mathbf{1}_{|\frac{u−X_i}{h}|\leq 1}du$

$=\frac{1}{nh}\sum_{i=1}^{n}\int_{-\infty}^{\frac{x−X_i}{h}}(1-|y|)\mathbf{1}_{|y|\leq 1}h dy$

$=\frac{1}{n}\sum_{i=1}^{n}\int_{-\infty}^{+\infty}(1-|y|)\mathbf{1}_{-1\leq y\leq 1}\mathbf{1}_{y\leq\frac{x−X_i}{h}}dy$

$=\frac{1}{n}\sum_{i=1}^{n}[\int_{-1}^{\min(1,\frac{x−X_i}{h})}(1-|y|)dy] \mathbf{1}_{-1<\frac{x−X_i}{h}}$

$=\frac{1}{n}\sum_{i=1}^{n}[\min(1,\frac{x−X_i}{h})+1-\int_{-1}^{\min(1,\frac{x−X_i}{h})}|y|dy]\mathbf{1}_{x>X_i-h}$

$=\frac{1}{n}\sum_{i=1}^{n}[\min(1,\frac{x−X_i}{h})(1-\frac{|\min(1,\frac{x−X_i}{h})|}{2})+\frac{1}{2}]\mathbf{1}_{x>X_i-h}$

• Thank you! I have some parts that I do not understand though. Why did the h disappear from step 2 to 3? In the last 2 steps, I think it should be 3/2 instead of 1/2. The +1 was missing. Also, would it be possible to simplify the equation further? – Stongals Mar 2 '16 at 3:32
• In step 3, h disappears because of the variable change $y=(x-X_i)/h$. – Jacky1 Mar 2 '16 at 6:43
• The last step is ok because the integral of |y| is y|y|/2, and I just factorize the result by $min$. I think it is maybe possible to simplify further. You can use indicator functions and distinguish the cases where $(x-X_i)/h\geq1$ and $(x-X_i)/h<1$. – Jacky1 Mar 2 '16 at 6:54