1

How would I go about simulating a Poisson process with a rate of lambda = 0.5 arrivals per time unit. The simulation needs to run until there are 8 arrivals, and from that I would like to create a plot that represents this. Could anyone lend a hand? Many thanks in advance.

1
  • 1
    Hey , your question is too broad. can you please provide some example code of what you already tried? May 1, 2020 at 23:03

1 Answer 1

4

The inter-arrival times of a Poisson process are independent and exponentially distributed with mean 1/lambda. Here is a reference.

Therefore, a simple way to simulate the first 8 arrivals of a Poisson process is using the accumulated sum of independent Exponential random variables (results may differ because they're random):

X <- cumsum(rexp(8, rate = 0.5))
# [1] 1.640417 1.855639 1.988687 2.936651 6.192125 7.682924 8.159302 8.963526

As for plotting it, depending on what kind if plot you need: A very simple option using the x-axis as time and y-axis as the number of occurrences until that point of time. Using ggplot2:

library(ggplot2)
ggplot(data.frame(t = X, count = seq_along(X)), aes(x = t, y = count)) +
  geom_step()

Result:

enter image description here

3
  • 1
    Well that's embarrasing. I've published papers and presented many abstracts on Poisson processes, but just misread this question. I have deleted my answer and upvoted yours. Thanks for pointing out my mistake. May 1, 2020 at 19:50
  • 1
    There is nothing to be embarrassment about! It is a very shortly-written probability question a on a programming website, definitely not the perfect setup :)
    – VFreguglia
    May 1, 2020 at 20:02
  • Wow, thank you for creating such a brilliant and coherent answer. I can learn a lot from this. May I ask if there is anything wrong with my original attempt of doing it? I probably took quite the detour in terms of coding but I ended up with a graph that seemed to work: >x <- rpois(30, 1/2) (chose an n that I thought would be sufficient) >plot(cumsum(x), ylab = "arrivals", xlab = "time, t", type = "s", ylim = c(0,8), main="Poisson Process")
    – SDebSDeb
    May 1, 2020 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.