简体   繁体   中英

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM