Density functions

plot(c(0,2),c(0,2), type="n",xlab="x", ylab="f(x)", axes=F)
lines(c(0,0), c(0,1))
lines (c(0,1), c(0,0))
lines(c(0,1), c(1,1))
lines (c(1,1), c(1,0))
lines(c(0,0), c(1,2))
lines (c(1,2), c(0,0))
lines(c(0.7,0.7),c(1,0))
text (0,1,"1",pos=2)
text (1,0,"1", pos=1)
text (0.7,0,"x", pos=1)
polygon(c(0,0.7,0.7,0),c(0,0,1,1),col='skyblue')
The probability density function (p.d.f.) and the cumulative distribution function (c.d.f.).
Details
\begin{defn}
If $X$ is a random variable such that \\
$$P(a\leq X\leq b)=\int\limits^{b}_{a}f(x)dx,$$\\
for some function $f$ which satisfies $f(x)\geq0$ for all $x$ and\\
$$\int\limits^\infty_{-\infty} f(x)dx = 1$$\\
then $f$ is said to be a {\bf probability density function (p.d.f.)} for $X$.\\
\end{defn}
\begin{defn}
The function
$$ F(x)= \int\limits^{x}_{-\infty} f(t)dt$$ is the {\bf cumulative distribution function (c.d.f.)}.
\end{defn}
Examples
\begin{xmpl}
Consider a random variable $X$ from the uniform distribution, denoted by $X\sim U(0,1)$. This distribution has density
$$
f(x) = \left \{ \begin{array}{rl}
1 &\mbox { if $0 \leq x \leq 1$} \\
0 &\mbox {e.w.}
\end{array} \right.
$$

The cumulative distribution function is given by
$$
P[X\leq x] = \int\limits^{x}_{-\infty} f(t)dt = \left\{ \begin{array}{rl}
0 &\mbox {if $x<0$}\\
x &\mbox {if $0 \leq x \leq 1$} \\
1
\end{array} \right.
$$
\end{xmpl}
\begin{xmpl}
Suppose $X \sim P(\lambda)$, where X may denote the number of events per unit time. The p.m.f. of X is described by $p(x)=P[X=x]=e^{-\lambda}\frac{\lambda^x}{x!}$ for $x=0,1,2,...$. Consider now the waiting time, T, between events, or simply until the first event. Consider the event $T>t$ for some number t>0. If $X\sim p(\lambda)$ denotes the number of events per unit time, then let $X_t$ denote the number of events during the time period for 0 through t. Then it is natural to assume

$X_t \sim P(\lambda t)$ and it follows that $T>t$ if and only if $X_t=0$ and we obtain $P[T>t]=P[X_t=0]=e^{-\lambda t}$.
It follows that the c.d.f. of T is $F_T(t)=P[T\leq t]=1-P[T>t]=1-e^{-\lambda t}$ for $t>0$.\\

The p.d.f. of T is therefore $f_T(t)=F_T'(t)=\frac{d}{dt}F_T(t)=\frac{d}{dt}(1-e^{-\lambda t}=0-e^{- \lambda t}*(-\lambda)=\lambda e^{-\lambda t}$ for $t \geq 0$ and $f_T(t)=0$ for $t=0$. \\

The resulting density
$$f(t) = \left\{ \begin{array}{rcl}
\lambda e^{-\lambda t} & \mbox{for}& t \geq0\\
0& \mbox{for} & t<0
\end{array}\right.$$
describes the exponential distribution.

This distribution has the expected value
$$E[T]=\int\limits^{\infty}_{-\infty} tf(t)dt=\int\limits^{\infty}_{0} t \lambda e^{-\lambda t}dt.$$

\textbf{the stuff below is all messed up...}

We set $u=\lambda t$ and $du=\lambda dt$ to obtain
$$\int ue^{-u}du= \frac{1}{\lambda}\int\limits^{\infty}_{0} ue^{-u}du=\frac{1}{\lambda}=
\int\limits^{\infty}_{0} 1 \cdot e^{-u}du$$

$$=\left [ -ue^{-u}\right ] _0^{\infty}$$

$$=\left[\frac{1}{\lambda}(-e^{-u})\right]_{0}^{\infty} -0=\frac{1}{\lambda} .$$
\end {xmpl}