YouTip LogoYouTip

R Func Rpois

# R rpois() Function - Generate Poisson Distribution Random Numbers [![Image 3: R Language Examples](https://example.com/images/up.gif) R Language Examples](https://example.com/r/r-examples.html) The R rpois() function is used to generate random numbers that follow a Poisson distribution. The Poisson distribution describes the number of random events occurring in a fixed time or space, and is commonly used to simulate website visits, phone calls, etc. The syntax of the rpois() function is as follows: rpois(n, lambda) dpois(x, lambda) # Probability Mass Function ppois(q, lambda) # Cumulative Distribution Function **Parameter Description:** * **n**: The number of random numbers to generate. * **lambda**: The average number of events per unit time (mean). ## Example # Simulate a website with an average of 5 visits per hour, generate 24 hours of visits set.seed(123) hourly_visits <-rpois(24, lambda =5) print("24 Visits per hour:") print(hourly_visits) # dpois: Probability of exactly 3 visits in one hour prob_3 <-dpois(3, lambda =5) print(paste("Probability of exactly 3 visits:", round(prob_3, 4))) # ppois: Probability of more than 8 visits in one hour prob_over_8 <-1-ppois(8, lambda =5) print(paste("Probability of exceeding 8 visits:", round(prob_over_8, 4))) Executing the above code outputs: "24 Visits per hour:" 4 6 7 3 4 6 6 7 3 1 5 6 6 6 4 6 3 3 4 5 4 10 4 4 "Probability of exactly 3 visits: 0.1404" "Probability of exceeding 8 visits: 0.0681" [![Image 4: R Language Examples](https://example.com/images/up.gif) R Language Examples](https://example.com/r/r-examples.html)
← R Func SampleR Func Rnorm β†’