Probability Density Functions (pdf)

Random variables that can assume every value in an interval have continuous distributions. A continuous distribution can also be characterized by its probability density function (p.d.f.).

Many experiments or observations of random phenomenon do not have integers as outcomes, but instead are measurements selected from an interval of numbers. For example, you could find the length of time that it takes when waiting in line at the grocery store or the weight of a bag of potato chips advertised at 1 oz. If the measurements could come from an interval of possible outcomes, we call them continuous-type data.

A probability density function (pdf) is a function \(f\) such that:

  1. \(f(x)\geq 0\) for all \(x\)
  2. \(\int f(x)dx=1\) over the domain of support.

Flame broiled example

Example

Suppose \(f_{Y}(y)=4y^{3}\), \(0\leq y\leq 1\). Is this a valid probability distribution?

Yes.

  1. \(f(y) >0\) over the domain of support. You can’t just state this, you have to show it:
y <- seq(0,1, by=.01)
f.y <- 4*y^3
plot(y, f.y)

  1. \(f(y)\) integrates to 1 over the domain of support.
f.y <- function(y){4*y^3}
integrate(f.y, lower=0, upper=1)
## 1 with absolute error < 1.1e-14

Definition 4.3: Continuous random variable

A continuous random variable \(X\) is a random variable described by a pdf in the sense that

\[ P(a \leq x \leq b) = \int_{a}^{b} f_{X}(x) dx \]

whenever \(a \leq b\), including the cases \(a=-\infty\) or \(b=\infty\).

Example

Let \(X\) be a random variable with the following p.d.f. \[ f(x)=\{ \begin{array}{cc} \frac{2}{3}x^{-1/3}& { for 0<x<1,}\\ 0& {otherwise}. \end{array} \]

Compute P\((X\leq 8/27)\).

\[ \int_{0}^{8/27} \frac{2}{3}x^{-1/3}dx = x^{2/3} \Biggr|_{0}^{8/27} = \frac{4}{9} \]

integrand <- function(y) { 2/3*y^(-1/3)}
integrate(integrand,lower= 0 ,upper= 8/27)
## 0.4444444 with absolute error < 6.7e-16
4/9 #confirm
## [1] 0.4444444

You try it

Do both by hand, and using R. Don’t forget to write your code down in these notes.

  1. Suppose \(f_{Y}(y)=4y^{3}\), \(0\leq y\leq 1\). Find \(P(0\leq Y\leq\frac{1}{2})\).

\[ P(0 \leq Y\leq\frac{1}{2}) = \int_{0}^{1/2} 4y^{3}dy = \\ y^{4} \Biggr|_{0}^{1/2} = \frac{1}{16} \]

  1. For the random variable \(Y\) with pdf \(f(y)=\frac{2}{3}+\frac{2}{3}y\) for \(0\leq y\leq 1\), find \(P(\frac{3}{4}\leq Y\leq 1)\).

\[ \begin{align} \int_{3/4}^{1} \Bigr(\frac{2}{3}+\frac{2}{3}y \Bigl) dy & = \frac{2}{3}y+\frac{1}{3}y^{2} \Biggr|_{3/4}^{1} \\ & = \Bigr(\frac{2}{3}+\frac{1}{3}\Bigl) - \Bigr(\frac{2}{3}*\frac{3}{4}+\frac{1}{3}*\Bigr(\frac{3}{4}\Bigl)^{2} \Bigl) \\ & = 1 - \Bigr(\frac{1}{2} + \frac{3}{16} \Bigl) \\ & = \frac{5}{16} \end{align} \]

Cumulative distribution function (cdf)

The cumulative distribution function (cdf) associated with \(X\) (either discrete or continuous) is the function \(F(x)=P(X\leq x)\), or written out in terms of the pdf’s and cdf’s.

\[ F(x)=P(X\leq x)=\int_{-\infty}^{x}f(t)dt \]

for continuous variables and \[ F(x)=P(X\leq x)=\sum_{n=-\infty}^{x}p(n) \] for discrete variables.

Theorem 4.1

Let \(X\) be a continuous random variable with pdf \(f\) and cdf \(F\).

  1. \(\frac{d}{dx}F=f.\)
  2. \(P(a\leq X\leq b)=F(b)-F(a)\)
  3. \(P(X\geq a)=1-F(a)=\int_{a}^{\infty}f(x)dx\)

Example

Find the cdf for the random variable \(Y\) for the following pdf: \[ f_{Y}(y)=4y^{3} \]

for \(0\leq y\leq 1\). Calculate \(P(0\leq Y \leq 1/2)\) using \(F_{Y}(y)\).

\[F(y)=P(Y\leq y)=\int_{0}^{y}4t^{3}dt=y^4\] \[P(Y\leq 0.5)=F\left(\frac{1}{2}\right)=\left(\frac{1}{2}\right)^{4}=\frac{1}{16}\]

Example

A random variable \(Y\) has CDF as follows:

\[ F(y)=\{ \begin{array}{cc} 0& for y<0\\ ln(y)&1\leq y\leq e\\ 1&e<y\\ \end{array} \]

  1. Find \(P(Y<2)\)

\[ln(2)\]

log(2)
## [1] 0.6931472
  1. Find \(P(2<Y\leq 2\frac{1}{2})\)

\[ ln(2.5) - ln(2)\]

log(2.5)-log(2)
## [1] 0.2231436
  1. Find \(P(2<Y<2\frac{1}{2})\)

Same as b)!

  1. \(f(y)\)

\(f(y)=\frac{d}{dy} F(y)=\frac{1}{y}\)

You try it

  1. The cdf for a random variable \(Y\) is defined by the following:

\[ F(y)= \Bigg\{ \begin{array}{cc} 0 & \mbox{for } y<0\\ 4y^{3}-3y^{4} & 0\leq y\leq 1\\ 1 & y > 1 \end{array} \] Find \(P(\frac{1}{4}<Y<\frac{3}{4})\).

I’ll solve this by defining function in R, and using it to calculate the definite integrals.

Fy <- function(y){4*y^3-3*y^4}
Fy(.75) - Fy(.25)
## [1] 0.6875
  1. Suppose \(F(y)=\frac{1}{12}\left(y^{3}+y^{2}\right)\), \(0\leq y\leq 2\). Find \(f(y)\).

\(\frac{d}{dy}F(y)=\frac{1}{12}\left(3y^{2}+2y\right)\)

  1. In a certain country, the distribution of a family’s disposable income, \(Y\), is described by the pdf \(f(y)=ye^{-y}\), \(y\geq 0\). Find \(F(y)\).

\[F(y) = P(Y\leq y) = \int_{0}^{y}te^{-t}dt\] Integrate by parts where \(u=t, du=dt, dv = e^{-t}dt, v = -e^{-t}\)

\[ -e^{-t}t + \int_{0}^{y}e^{-t}dt = -e^{-t}t - e^{-t}\Biggr|_{0}^{y} = 1 - e^{-y}(y+1) \]

So \(F(y) = 1 - e^{-y}(y+1)\)