Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ORIGINAL CODE: # In this simulation the library numpy is used and it is named it np import numpy as np # The

ORIGINAL CODE:
# In this simulation the library numpy is used and it is named it "np"
import numpy as np
# The seed below initializes the random generator to always obtain the same result.
# DO NOT CHANGE THIS VALUE AND RERUN THIS CELL EVERYTIME YOU RUN THE PROGRAM.
np.random.seed(3500)
# Variables are defined in this cell
v =16/60 # Rate of vehicles per second
queueMoveTime =1.5 # Time it takes a vehicle to clear the intersection
redTime =60 # Red light time in seconds
greenTime =60 # Green light time in seconds
nVehi =0 # Number of vehicles arriving at the intersection
nRep =0 # Counter for number of repetitions
nQueue =0 # Counter for number of times vehicles queue
isRed = True # Initialize the light as red
isGreen = False
# Monte Carlo simulation
nsim =100000 # Number of simulation
while nRep nsim:
# Red light cycle
if isRed:
nRep = nRep +1 # Count replicates
nVehi = nVehi + np.random.poisson(v * redTime)
isRed = False
isGreen = True
# Green light cycle
else:
time = queueMoveTime
while isGreen:
if nVehi >0:
nVehi = nVehi -1
nVehi = nVehi + np.random.poisson(v * queueMoveTime)
else:
break
time = time + queueMoveTime
if time >= greenTime:
break
if nVehi >0:
nQueue = nQueue +1
# Reset light to Red
isRed = True
isGreen = False
# Calculate the probability of queuing
pQueue = nQueue / nsim
print("The probability of queuing at the intersection is ", pQueue). Answer question in image using this info.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

What is meant by the term industrial relations?

Answered: 1 week ago