Lucas Brawdy
Lucas Brawdy

Reputation: 49

Python average Interval and exponential distribution

Im working on an assignment that required me to calculate arrivals that come in an average of a 15 minute interval and follow an exponential distribution. I havent worked with Python a ton and dont know if im doing it right. This is my code:

[random.expovariate(.15) for i in range(50)]

Any insight will be appreciated!

Upvotes: 2

Views: 949

Answers (1)

eclique
eclique

Reputation: 178

intervals = [random.expovariate(1./15) for i in range(50)]

will generate 50 time intervals (in minutes) between arrivals, that will average in 15 minutes. I. e., first arrival will occur at interval[0], second one at interval[0] + interval[1], and so on. Note, that it's 1./15, not .15.

If by "calculate arrivals" you mean to get the binary array of 50 elements with 1's corresponding to arrivals, then you should have a look at a Poisson process, since exponential distribution describes the time between events in a Poisson process.

Upvotes: 1

Related Questions