# Example code for finding Poisson probabilities in R # To get the cumulative probability, the syntax is: rpois(x, lambda) # where lambda and x are values that you fill in # Example 1 from class notes on the Poisson: # X is Poisson with lambda=1. # P(X <= 1): ppois(1, lambda=1) # P(X >= 3) = 1 - P(X <= 2) 1 - ppois(2, lambda=1) # P(X=2) = P(X <=2) - P(X<=1): ppois(2, lambda=1) - ppois(1, lambda=1) # or simply: dpois(2, lambda=1) # Example 2 from class notes on the Poisson: # X is Poisson with lambda=6. # P(X >= 5) = 1 - P(X <= 4): 1 - ppois(4, lambda=6) # P(X <= 9) - P(X<=6): ppois(9, lambda=6) - ppois(6, lambda=6) # Another example: # Suppose our random variable X is Poission with lambda = 12.33. # Let's answer the following questions # 1. What is the probability of 15 or fewer occurrences? P(X <= 15) ppois(15, lambda=12.33) # 2. What is the probability of EXACTLY 6 successes? P(X = 6) ppois(6, lambda=12.33) - ppois(5, lambda=12.33) # or simply: dpois(6, lambda=12.33) # 3. What is the probability of more than 13 successes? P(X > 13) 1 - ppois(13, lambda=12.33) # 4. What is the probability of 13 or more successes? P(X >= 13) 1 - ppois(12, lambda=12.33) # 5. What is the probability of 8, 9, or 10 successes? P(8 <= X <= 10) ppois(10, lambda=12.33) - ppois(7, lambda=12.33) # This R program will give us the answers to all these questions in an instant.