GaryBAYLOR / R-code

A collection of algorithms written by myself for solving statistical problems
0 stars 0 forks source link

Use Normal to approximate Poisson when lambda is large #4

Open GaryBAYLOR opened 9 years ago

GaryBAYLOR commented 9 years ago

When lambda is large, we can use Normal(lambda, lambda) to approximate Poisson (This can be proved by using Continuity Theorem). The following is R code and output.

Pois2Norm <- function(lambda = 100, n=1000) {
    x <- rpois(n, lambda)
    minx <- min(x)
    maxx <- max(x)
    plot(density(x), main = "Use Normal to approximate Poisson when lambda is large", xlab = "X")
    xnorm <- seq(from = minx, to = maxx, length = n)
    lines(xnorm, dnorm(xnorm, mean = lambda, sd = sqrt(lambda)), col = "red")
    x.pos <- minx + 0.01*(maxx - minx)
    miny <- min(density(x)$y)
    maxy <- max(density(x)$y)
    y.pos <- maxy - 0.01*(maxy - miny)
    legend(x.pos, y.pos, lty = c(1, 1), col  = c("black", "red"), legend = c("Poisson", "Normal"))
}

When lambda = 10, image When lambda = 100, image When lambda = 1000, image