1. Please answer the following in Python 3 code. Please answer all questions and
ID: 3756065 • Letter: 1
Question
1. Please answer the following in Python 3 code. Please answer all questions and share code and ouputs.
Bus arrival times.
Shuttle buses arrive at an airport to fetch passengers with an average interval of 15 minutes. Their actual interarrival times follow an **exponential distribution**.
---
Write a function `simulate_busses(mean, num_busses)` that simulates bus arrival times
- Use a ```random``` module to generate the exponentially distributed bus intervals.
- Round your raw data to the nearest tenth of a minute. Realize that rounding is generally scary, and can cause serious problems downstream if not done only when appropriate.
Call your function to generate a list of 50 arrival times with mean 15; capture the result in a variable called `bus_times`. Print your list, and be sure to commit the output.
For example, your list might begin ```[11.2, 34.1, 18.8, 23.5, ...```.
---
Use Python to answer the following questions:
1. What is the shortest waiting time in your list?
2. What is the longest waiting time?
These answers must be programmatically determined and the output that proves you computed them (namely, the values) must be committed.
---
When answering the previous question, did you write a function? Why or why not?
Explanation / Answer
Write a function `simulate_busses(mean, num_busses)` that simulates bus arrival times
- Use a ```random``` module to generate the exponentially distributed bus intervals.
- Round your raw data to the nearest tenth of a minute. Realize that rounding is generally scary, and can cause serious problems downstream if not done only when appropriate.
Call your function to generate a list of 50 arrival times with mean 15; capture the result in a variable called `bus_times`. Print your list, and be sure to commit the output.
For example, your list might begin ```[11.2, 34.1, 18.8, 23.5, ...```.
def printMaxActivities(s , f ):
n = len(f)
print "The following activities are selected"
# The first activity is always selected
i = 0
print i,
# Consider rest of the activities
for j in xrange(n):
# If this activity has start time greater than
# or equal to the finish time of previously
# selected activity, then select it
if s[j] >= f[i]:
print j,
i = j
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.