Sunday, July 19, 2009

Exponential density 2

Think of e as a function (rather than the irrational number 2.71828...).

In R:

e <- function(x) { 2.71828**(x) }

Then, e can be defined as the function whose derivative is itself. To see this:


f <- function(x) {
col=colors[x]) }
for (i in 1:4) f(i)

What did we do? First, we plotted the exponential function exp between 0 and 5 (heavy black line). Then, for each x in the series 1:4, we calculated y=exp(x) and plotted the point x,y in color. At the same time, we constructed a line with slope (y+y)/2 = y, passing through x,y. It is clear that the slope of the curve is equal to the value of the function at that point.

Another fun way to see this is to look at the infinite series for ex:

Can you see that the derivative with respect to x of this series is identical to the series itself?

Using simple calculus (the chain rule), we can also show that

Looking at the probability density function (pdf) for the exponential distribution,

and cumulative distribution function, we confirm that the pdf is the derivative of the cdf, as it should be. The cdf is:

No comments: