Lab3: Continuous Distributions


Getting Started with R

Click on the R icon

If no R icon, go to Start and then All Programs to find R


The Binomial Distribution

(some from Dr. Geyer's web page)

Every distribution that R handles has four functions. There is a root name, for example, the root name for the normal distribution is norm. This root is prefixed by one of the letters

We have already seen that for the binomial distribution, these functions are pbinom, qbinom, dbinom, and rbinom.

For the exponential distribution these functions are pexp, qexp, dexp, and rexp.

For help, use the help function on one of the four functions above.

What arguments are needed to specify the parameters of the exponential?


Example: the Exponential Distribution

Let's go through some functions of the exponential distribution.

First, put 200 equally spaced points in the range of 0 to 5.

> x <- seq(0,5,length=200)
Evaluate exponential density function (pdf) with rate parameter = 1. What is the mean of the RV?
> yd <- dexp(x)
Evaluate the exponential distribution function (cdf) with rate parameter = 1.
> yp <- pexp(x)
Now, let's compare these 2 functions by plotting with 2 plots per page.
par(mfrow=c(2,1))
plot(x, yd, type="l", main="Exponential Density Function")
plot(x,yp,type="l",main="Exponential Distribution Function")
Repeat the above using a different rate parameter. How do the plots change?


Example: The Normal Distribution

Let's repeat the above but with a standard normal distribution.

We will need a different range for the equally spaced points. Why?
How about the range -3 to 3?

xn <- seq(-3,3,length=200)
ydn <- dnorm(xn)
plot(xn, ydn, type="l", main="Normal Density Function")
plot(xn, pnorm(xn), type="l", main="Normal Distribution Function")
Repeat the above using a different mean and sd. How do the plots change?


The Central Limit Theorem (CLT)

What is the CLT?

Here is a good CLT Example

Here is some R code clt.r to demonstrate the CLT.