MATH MODELING CLASS USING MATH LAB In the posed elevator problem, your assistant
ID: 3884243 • Letter: M
Question
MATH MODELING CLASS USING MATH LAB
In the posed elevator problem, your assistant notified you that there are 60 workers operating on each of 5 floors atop the ground floor in your office building - 300 in total. The elevator occupancy is 10 people, and there are 3 elevators in total. In the worst-case scenario in terms of total transition time, on each elevator ride at least one person is getting off at each floor. Naturally, we can ask: what is the probability that an elevator with 10 passengers has none of the 5th floor workers? For that trip, it should reduce the elevator travel time by t45 + texit + t54 = 5 + 15 + 5 = 25sec. To see how often this might happen, we can perform random draws of elevator occupants, and average over a long time. This is a way to check the validity of certain modeling assumptions.
Part 1 Write a script which computes random draws for the 10 elevator occupants, and perform this 1000 times. Count the number of times a 5th floor occupant is present, and divide the that count by 1000. A basic structure for this may look like:
N=1000;
f o r . . . % loop ove r a l l N t r i e s
Elev= % g e n e r a t e v al u e s f o r Elev u si ng pseudorandom numbers
i f % put a c o n di ti o n on v al u e s to check f o r a 5 th f l o o r worker
% inc remen t co u n t e r
e l s e
% do no thing ( can l e a v e e l s e s ta temen t blank )
end
% do more t hi n g s i f n e c e s s a r y
end
% output count / N A very useful matlab command to look up would be "randi" or similarly "rand".
Explanation / Answer
%% MATH MODELING CLASS USING MATH LAB - PART1
% initial counter value
counter = 0;
% loop count
n=1000;
% Looping over n times
for k=1:n
% generating random numbers -- randi(numer of floors:300, rows:1, cols:number of occupants:10)
occupants = randi(300, 1, 10);
% calculating number of 5th floor occupants among 10 occupants
% mod(a, m) - function calculates the remainder value when divison happens
% between two numbers
% nnz(v) -- calculates number of ones in the logical array
numberOf5thFloorOccupants = nnz( mod(occupants, 5) == 0) ;
% incrementing the counter value
counter = counter + numberOf5thFloorOccupants;
end
% dividing counter value by number of loop iterations
output = counter / n;
% displaying output
disp(["output : ", output]);
Sample Output:
"output : " "2.027"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.