Compute Randomly Drawn Poisson Density in R Programming – rpois() Function

rpois() function in R Language is used to compute random density for poisson distribution.

Syntax: rpois(N, lambda)

Parameters:
N: Sample Size
lambda: Average number of events per interval

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to compute random
# Poisson Density
  
# Setting seed for
# random number generation
set.seed(1000)
  
# Set sample size
N <- 20
  
# Calling rpois() Function
y <- rpois(N, lambda = 5)
y

chevron_right


Output:

 [1] 4 6 2 6 5 2 6 5 3 3 4 6 4 7 7 2 5 6 2 5

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to compute random
# Poisson Density
  
# Setting seed for
# random number generation
set.seed(1000)
  
# Set sample size
N <- 100
  
# Calling rpois() Function
y <- rpois(N, lambda = 15)
  
# Plot a graph
plot(y)

chevron_right


Output:

My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.