05-Jan-2023 17:46:20 digital_dice_test(): MATLAB/Octave version 4.2.2 Test digital_dice(). aandb(): In game A, you flip a biased coin, which shows heads with probabiity] 1/2 - epsilon; you win a dollar on heads. In game B, you have two biased coins. If, at the time just before you decide to flip, your capital M is a multiple of 3 dollars, you chose coin 1, which shows heads with probability 1/10 - epsilon, otherwise you choose coin 2, which shows heads with probability 3/4 - epsilon. Both games A and B are losing games for you. But, paradoxically, if you randomly switch back and forth between one game and the other, you end up winning over the long term. Use graphics to display the winnings. Graphics saved as "aandb.png" average(): Use a Monte Carlo sample to estimate pi. Estimate for pi = 3.13939 Error = 0.00220472 Antithetic estimate for pi = 3.13869 Error = 0.00290698 baby_boom(): There are given probabilities of a man having 0, 1, 2, 3, 4, 5, 6 or 7 sons. What are the chances of having: 2 sons in the second generation? 4 sons in the second generation? 6 sons in the third generation? Estimated probabilities: 2 males in generation 2 = 0.0677 4 males in generation 2 = 0.0368 6 males in generation 3 = 0.0191 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.5 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 1.3241 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.5 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 1.9862 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.5 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 4.5699 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.5 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 5.1476 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.5 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 18.718 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.4 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 1.3903 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.4 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 2.0802 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.4 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 4.7401 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.4 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 5.3635 broke(): Three players begin with L, M and N dollars. On each turn, each player flips a coin. All coins have the same bias P = 0.4 If one player is "odd man out", he pays a dollar to each other player. When a player is bankrupt, the game is over. What is the average number of turns required? Average number of turns = 19.3036 bus(): 1 bus lines are available at a bus stop. In any hour, each bus line will come to the stop at a random time. A passenger arrives at the bus stop at a random time. What is the average wait for a bus? Estimated waiting time = 0.499246 Theoretical time = 0.5 bus(): 2 bus lines are available at a bus stop. In any hour, each bus line will come to the stop at a random time. A passenger arrives at the bus stop at a random time. What is the average wait for a bus? Estimated waiting time = 0.333145 Theoretical time = 0.333333 bus(): 3 bus lines are available at a bus stop. In any hour, each bus line will come to the stop at a random time. A passenger arrives at the bus stop at a random time. What is the average wait for a bus? Estimated waiting time = 0.249815 Theoretical time = 0.25 bus(): 4 bus lines are available at a bus stop. In any hour, each bus line will come to the stop at a random time. A passenger arrives at the bus stop at a random time. What is the average wait for a bus? Estimated waiting time = 0.200558 Theoretical time = 0.2 bus(): 5 bus lines are available at a bus stop. In any hour, each bus line will come to the stop at a random time. A passenger arrives at the bus stop at a random time. What is the average wait for a bus? Estimated waiting time = 0.167089 Theoretical time = 0.166667 car(): Park 3 cars in a line, and compute each car's nearest neighbor Estimate the probability that a given car is the nearest neighbor of its nearest neighbor. Estimated probability = 0.666667 Theoretical probability is 0.666667 car(): Park 10 cars in a line, and compute each car's nearest neighbor Estimate the probability that a given car is the nearest neighbor of its nearest neighbor. Estimated probability = 0.66534 Theoretical probability is 0.666667 car(): Park 20 cars in a line, and compute each car's nearest neighbor Estimate the probability that a given car is the nearest neighbor of its nearest neighbor. Estimated probability = 0.66607 Theoretical probability is 0.666667 car(): Park 30 cars in a line, and compute each car's nearest neighbor Estimate the probability that a given car is the nearest neighbor of its nearest neighbor. Estimated probability = 0.66672 Theoretical probability is 0.666667 chess(): A has to play three games of chess against B and C. A beats B with probability P, C with probability Q A has a choice of schedules: BCB or CBC. To win the tournament, A must win two successive games. Which schedule is better? Estimated win probability for BCB is = 0.7907 Estimated win probability for CBC is = 0.8647 chess(): A has to play three games of chess against B and C. A beats B with probability P, C with probability Q A has a choice of schedules: BCB or CBC. To win the tournament, A must win two successive games. Which schedule is better? Estimated win probability for BCB is = 0.3895 Estimated win probability for CBC is = 0.5728 chess(): A has to play three games of chess against B and C. A beats B with probability P, C with probability Q A has a choice of schedules: BCB or CBC. To win the tournament, A must win two successive games. Which schedule is better? Estimated win probability for BCB is = 0.1915 Estimated win probability for CBC is = 0.205 chess(): A has to play three games of chess against B and C. A beats B with probability P, C with probability Q A has a choice of schedules: BCB or CBC. To win the tournament, A must win two successive games. Which schedule is better? Estimated win probability for BCB is = 0.0631 Estimated win probability for CBC is = 0.076 committee(): From a faculty of 6 professors, 6 associate professors, 10 assistant professors, and 12 instructors, a committee of size 6 is formed randomly. What is the probablity that there is at least one person of each rank in the committee? Estimated probability = 0.3789 Exact probablity = 0.379031 deli(): A deli is open for 36,000 seconds. There are 1 or 2 clerks. Customers arrive at random. The amount of time it takes to service a customer is random. Customers are served in order. A clerk serves one customer at a time. Newly arrived customers wait in a queue if no clerk is available. What is the average and maximal times spent per customer? What is the average and maximal queue length? What percentage of time are the clerks idle? Average total time at deli 503.44 Maximum time at deli 1528 Average queue length 3.08908 Maximum queue length 13 Percent idle time clerk1 19.3667 Percent idle time clerk2 0 deli(): A deli is open for 36,000 seconds. There are 1 or 2 clerks. Customers arrive at random. The amount of time it takes to service a customer is random. Customers are served in order. A clerk serves one customer at a time. Newly arrived customers wait in a queue if no clerk is available. What is the average and maximal times spent per customer? What is the average and maximal queue length? What percentage of time are the clerks idle? Average total time at deli 105.872 Maximum time at deli 888 Average queue length 0.148944 Maximum queue length 6 Percent idle time clerk1 51.6167 Percent idle time clerk2 75.2583 deli(): A deli is open for 36,000 seconds. There are 1 or 2 clerks. Customers arrive at random. The amount of time it takes to service a customer is random. Customers are served in order. A clerk serves one customer at a time. Newly arrived customers wait in a queue if no clerk is available. What is the average and maximal times spent per customer? What is the average and maximal queue length? What percentage of time are the clerks idle? Average total time at deli 9663.06 Maximum time at deli 17302 Average queue length 113.037 Maximum queue length 216 Percent idle time clerk1 0.827778 Percent idle time clerk2 0 deli(): A deli is open for 36,000 seconds. There are 1 or 2 clerks. Customers arrive at random. The amount of time it takes to service a customer is random. Customers are served in order. A clerk serves one customer at a time. Newly arrived customers wait in a queue if no clerk is available. What is the average and maximal times spent per customer? What is the average and maximal queue length? What percentage of time are the clerks idle? Average total time at deli 852.506 Maximum time at deli 2139 Average queue length 9.97564 Maximum queue length 27 Percent idle time clerk1 1.10556 Percent idle time clerk2 2.19722 dinner(): N guests sit down at a dinner table, without noticing the name tags. What are the chances that no one sits at their assigned seat? N P(derangement) 1 0 2 0.5 3 0.3333333333333333 4 0.375 5 0.3666666666666667 6 0.3680555555555556 7 0.3678571428571428 8 0.3678819444444444 9 0.367879188712522 10 0.3678794642857143 11 0.3678794392336059 12 0.3678794413212816 13 0.3678794411606912 14 0.3678794411721619 15 0.3678794411713971 16 0.367879441171445 17 0.3678794411714422 18 0.3678794411714424 19 0.3678794411714424 20 0.3678794411714423 dish(): Five dishwashers work together. Five dishes are broken. What are the chances that at least four of the dishes are broken by the same particular dishwasher? Probability dishwasher #1 breaks at least 4 out of 5 dishes = 0.005 Theoretical probability is 0.00672 easywalk(): A pedestrian begins 1000 blocks east and 1000 blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the exact expected wait for stop lights? Use graphics to display the expected results. Graphics saved as "easywalk.png" election(): N voters participate in an election. n of the voters are candidates. Voting rules may allow a voter to vote for themselves, or not. M votes are required in order for a leader to be chosen. What is the probability that, on a single vote, a leader will be chosen? Probability a leader was selected = 1 election(): N voters participate in an election. n of the voters are candidates. Voting rules may allow a voter to vote for themselves, or not. M votes are required in order for a leader to be chosen. What is the probability that, on a single vote, a leader will be chosen? Probability a leader was selected = 0.7721 election(): N voters participate in an election. n of the voters are candidates. Voting rules may allow a voter to vote for themselves, or not. M votes are required in order for a leader to be chosen. What is the probability that, on a single vote, a leader will be chosen? Probability a leader was selected = 0.0581 election(): N voters participate in an election. n of the voters are candidates. Voting rules may allow a voter to vote for themselves, or not. M votes are required in order for a leader to be chosen. What is the probability that, on a single vote, a leader will be chosen? Probability a leader was selected = 0.1066 estimate(): N runners participate in a marathon. Each runner wears a tag with their index, from 1 to N. We observe the values of K of these tags. We want to estimate N. Produce illustrative plots for several cases. Graphics saved as "estimate.png" floss(): A person buys two rolls of dental floss. Each roll has 40 feet of floss. The person randomly selects a roll and takes 1 foot of floss. When one roll runs out, how many feet remain in the other roll? Average remaining floss = 7.11423 floss(): A person buys two rolls of dental floss. Each roll has 150 feet of floss. The person randomly selects a roll and takes 1 foot of floss. When one roll runs out, how many feet remain in the other roll? Average remaining floss = 13.8083 forgetful_burglar(): In a town of 201 homes, a burglar starts at home 101. He randomly moves one or two homes left or right. What is the typical number of moves he will make before revisiting a home? K Prob(K) 1 0 2 0.2427 3 0.2893 4 0.1903 5 0.1143 6 0.0689 7 0.0401 8 0.0242 9 0.0149 10 0.0067 Graphics saved as "fb.png" gameb(): In game B, you have two biased coins. If, at the time just before you decide to flip, your capital M is a multiple of 3 dollars, you chose coin 1, which shows heads with probability 1/10 - epsilon, otherwise you choose coin 2, which shows heads with probability 3/4 - epsilon. Game B is a losing game for you, and this code simply demonstrates that using many simulations. Produce a plot showing how the player loses. Graphics saved as "gameb.png" gs(): A building has 7 floors, and there are n elevators, each of which is at a randomly chosen floor. A person on floor 2 requests an elevator, wishing to go up. What is the probability that the first elevator to arrive is going down? Estimated probability of down elevator = 0.837 Theoretical probability is 0.833333 gs(): A building has 7 floors, and there are n elevators, each of which is at a randomly chosen floor. A person on floor 2 requests an elevator, wishing to go up. What is the probability that the first elevator to arrive is going down? Estimated probability of down elevator = 0.7205 Theoretical probability is 0.722222 gs(): A building has 7 floors, and there are n elevators, each of which is at a randomly chosen floor. A person on floor 2 requests an elevator, wishing to go up. What is the probability that the first elevator to arrive is going down? Estimated probability of down elevator = 0.6412 Theoretical probability is 0.648148 guess(): Given M items of ranks 1 through M, randomly guess the rank of each item. On average, how many ranks will we guess correctly? Average number of correct pairings = 1.0022 Expected value is 1. jury(): There are 5 judges on an appeals court. Each judge has a probability of making a correct ruling. What is the probability that a majority of the judges will rule incorrectly? Probability of a mistaken judgement = 0.0069 kelvin(): A biased coin comes up heads with probability 0.4. To get a unbiased random value, toss the coin twice. If you get TH, call it heads; if you get HT, call it tails. If you get TT or HH, do another double toss. On average, how many double tosses are necessary? Average number of double tosses = 2.0759 Theoretical value = 2.08333 malt(): Lil and Bill agree to meet in the malt shop between 3:30 and 4:00. Each arrives at a random time. Lil will wait 5 minutes, then leave. Bill will wait 7 minutes, then leave. What is the probability of a meeting? Estimated meeting probability = 0.3603 Theoretical probability is 0.358889 missing(): There are 100 senators. A bill needs a majority of present senators to pass. A senators are against the bill. M senators are missing the vote. What is the probability that the bill will be defeated? Probability of defeat = 0.133 missing(): There are 100 senators. A bill needs a majority of present senators to pass. A senators are against the bill. M senators are missing the vote. What is the probability that the bill will be defeated? Probability of defeat = 0.061 missing(): There are 100 senators. A bill needs a majority of present senators to pass. A senators are against the bill. M senators are missing the vote. What is the probability that the bill will be defeated? Probability of defeat = 0.185 mono(): Expected value of the number of random numbers that can be generated, which are monotone increasing. Extimated expected length = 2.7142 Expected value is 2.71828. obtuse(): Define a "random" triangle as half of a rectangle with height 1 and width 1 <= L. What are the chances the triangle is obtuse? Using value L = 1 Estimated likelihoood of obtuse triangle = 0.7245 For L=1, expected value = 0.725206 For L=2, expected value = 0.798374 obtuse1(): Define a "random" triangle by splitting the unit interval into three random pieces. What are the chances the triangle is obtuse? Estimated likelihoood of obtuse triangle = 0.166 Exact value is 0.170558 optimal(): A dating club offers 11 potential partners. It turns out that any of 2 of these partners would be acceptable. The dater gets 1 date with each partner, but immediately after the date, must either marry that partner, or move to the next date. The dater plans to date a sample of the partners without a marriage offer, and then marry the next partner who is better than all the sample dates. As the sample size is varied, what are the chances of happiness? Use graphics to display result. Graphics saved as "optimal.png" optimal(): A dating club offers 50 potential partners. It turns out that any of 5 of these partners would be acceptable. The dater gets 1 date with each partner, but immediately after the date, must either marry that partner, or move to the next date. The dater plans to date a sample of the partners without a marriage offer, and then marry the next partner who is better than all the sample dates. As the sample size is varied, what are the chances of happiness? Use graphics to display result. Graphics saved as "optimal.png" patrol(): Consider a divided highway, and suppose it could be divided by a grassy median or a concrete barrier. Suppose NUMBER police cars patrol the highway. Suppose an accident occurs at a randomly chosen location and lane. Suppose all patrol cars immediately head towards the accident. If a grassy median, then patrol cars in the wrong lane can immediately reverse direction. For the concrete barrier, patrol cars in the wrong lane must continue to the end of the highway and then turn around. Estimate the average time required by a patrol car to reach the accident. Average grass distance = 0.332358 Average concrete distance = 1.01366 patrol(): Consider a divided highway, and suppose it could be divided by a grassy median or a concrete barrier. Suppose NUMBER police cars patrol the highway. Suppose an accident occurs at a randomly chosen location and lane. Suppose all patrol cars immediately head towards the accident. If a grassy median, then patrol cars in the wrong lane can immediately reverse direction. For the concrete barrier, patrol cars in the wrong lane must continue to the end of the highway and then turn around. Estimate the average time required by a patrol car to reach the accident. Average grass distance = 0.211047 Average concrete distance = 0.669338 patrol(): Consider a divided highway, and suppose it could be divided by a grassy median or a concrete barrier. Suppose NUMBER police cars patrol the highway. Suppose an accident occurs at a randomly chosen location and lane. Suppose all patrol cars immediately head towards the accident. If a grassy median, then patrol cars in the wrong lane can immediately reverse direction. For the concrete barrier, patrol cars in the wrong lane must continue to the end of the highway and then turn around. Estimate the average time required by a patrol car to reach the accident. Average grass distance = 0.151754 Average concrete distance = 0.502482 patrol(): Consider a divided highway, and suppose it could be divided by a grassy median or a concrete barrier. Suppose NUMBER police cars patrol the highway. Suppose an accident occurs at a randomly chosen location and lane. Suppose all patrol cars immediately head towards the accident. If a grassy median, then patrol cars in the wrong lane can immediately reverse direction. For the concrete barrier, patrol cars in the wrong lane must continue to the end of the highway and then turn around. Estimate the average time required by a patrol car to reach the accident. Average grass distance = 0.115604 Average concrete distance = 0.403375 patrol(): Consider a divided highway, and suppose it could be divided by a grassy median or a concrete barrier. Suppose NUMBER police cars patrol the highway. Suppose an accident occurs at a randomly chosen location and lane. Suppose all patrol cars immediately head towards the accident. If a grassy median, then patrol cars in the wrong lane can immediately reverse direction. For the concrete barrier, patrol cars in the wrong lane must continue to the end of the highway and then turn around. Estimate the average time required by a patrol car to reach the accident. Average grass distance = 0.09489 Average concrete distance = 0.332306 pierror(): Estimate pi by counting random points in the unit square which are also in the quarter circle. Using 10000 points, estimate is 0.7864, absolute error 2.35519 ranking(): A list of 24 items is given. The test taker is required to give a rank for each. For each item, the test taker randomly chooses a value between 1 and M. What is the average number of correct rankings? Average number of correct matches = 1.007 rhs(): Random Harmonic Series: Compute and histogram many values of the partial sums of sum ( 1 <= k < infinity ) t(i) / k where t(i) is randomly +1 or -1. Graphics saved as "rhs.png" rolls(): Two rolls of toilet paper are installed in a toilet, with 200 sheets. There are two kinds of people, with probabilities p and 1-p. * big choosers take one sheet from the larger roll; * little choosers take one sheet from the smaller roll (unless empty). When one roll becomes empty, how many sheets are on the other roll? Use graphics to display results. Graphics saved as "rolls.png" smoker(): A smoker buys two packs of 40 matches. He then repeatedly selects a match from a randomly chosen pack. When one pack runs out, how many matches have been used in total? Average total number of matches used = 72.9023 Graphics saved as "smoker.png" smokerb(): A smoker buys two packs of 40 matches. He then repeatedly selects a match from a randomly chosen pack. At some point, the pack he chooses will be empty. How many matches have been used by then? Average total number of matches used = 73.6734 Graphics saved as "smokerb.png" spin(): A game involves two spinnable disks, each divided into three sectors. A player spins disk 1 or 2 according to the following rules: * if the player spins disk i, and it stops in region Pij, he moves from disk i to disk j; * if the spinner stops in region Pi3, the game ends. * if the game ends in P13, the player wins. What is the probablity that the player, starting with disk 1, wins? Probabiity of winning = 0.6615 Theoretical value = 0.65 steve(): Steve gets on an elevator going up. There are 11 higher floors. Steve wishes to go up 9 floors. There are K additional riders in the elevator, each of whom has randomly chosen one of the 11 higher floors as destination. On average, how many times will the elevator stop until Steve reaches his floor? Estimated number of stops = 1 Theoretical number is 1 steve(): Steve gets on an elevator going up. There are 11 higher floors. Steve wishes to go up 9 floors. There are K additional riders in the elevator, each of whom has randomly chosen one of the 11 higher floors as destination. On average, how many times will the elevator stop until Steve reaches his floor? Estimated number of stops = 1.7205 Theoretical number is 1.72727 steve(): Steve gets on an elevator going up. There are 11 higher floors. Steve wishes to go up 9 floors. There are K additional riders in the elevator, each of whom has randomly chosen one of the 11 higher floors as destination. On average, how many times will the elevator stop until Steve reaches his floor? Estimated number of stops = 2.3897 Theoretical number is 2.38843 steve(): Steve gets on an elevator going up. There are 11 higher floors. Steve wishes to go up 9 floors. There are K additional riders in the elevator, each of whom has randomly chosen one of the 11 higher floors as destination. On average, how many times will the elevator stop until Steve reaches his floor? Estimated number of stops = 2.9934 Theoretical number is 2.98948 steve(): Steve gets on an elevator going up. There are 11 higher floors. Steve wishes to go up 9 floors. There are K additional riders in the elevator, each of whom has randomly chosen one of the 11 higher floors as destination. On average, how many times will the elevator stop until Steve reaches his floor? Estimated number of stops = 5.6062 Theoretical number is 5.60722 stopping(): From a population of 5 indexed values, the highest is sought. Values are to be discovered in order of index. When value I is discovered: * it may be rejected, and the next value discovered, or * it may be accepted, and the process is terminated. A strategy is to view S items in a row, and then accept the very next item that is larger than max(S). Given N, what is S, and what are the chances that this process will produce the maximum? Population size N = 5 Optimal sample size S = 2 Ratio N / S = 2.5 Probability of success = 0.433333 stopping(): From a population of 10 indexed values, the highest is sought. Values are to be discovered in order of index. When value I is discovered: * it may be rejected, and the next value discovered, or * it may be accepted, and the process is terminated. A strategy is to view S items in a row, and then accept the very next item that is larger than max(S). Given N, what is S, and what are the chances that this process will produce the maximum? Population size N = 10 Optimal sample size S = 3 Ratio N / S = 3.33333 Probability of success = 0.39869 stopping(): From a population of 20 indexed values, the highest is sought. Values are to be discovered in order of index. When value I is discovered: * it may be rejected, and the next value discovered, or * it may be accepted, and the process is terminated. A strategy is to view S items in a row, and then accept the very next item that is larger than max(S). Given N, what is S, and what are the chances that this process will produce the maximum? Population size N = 20 Optimal sample size S = 7 Ratio N / S = 2.85714 Probability of success = 0.384209 stopping(): From a population of 50 indexed values, the highest is sought. Values are to be discovered in order of index. When value I is discovered: * it may be rejected, and the next value discovered, or * it may be accepted, and the process is terminated. A strategy is to view S items in a row, and then accept the very next item that is larger than max(S). Given N, what is S, and what are the chances that this process will produce the maximum? Population size N = 50 Optimal sample size S = 18 Ratio N / S = 2.77778 Probability of success = 0.374275 stopping(): From a population of 100 indexed values, the highest is sought. Values are to be discovered in order of index. When value I is discovered: * it may be rejected, and the next value discovered, or * it may be accepted, and the process is terminated. A strategy is to view S items in a row, and then accept the very next item that is larger than max(S). Given N, what is S, and what are the chances that this process will produce the maximum? Population size N = 100 Optimal sample size S = 37 Ratio N / S = 2.7027 Probability of success = 0.371043 sylvester_quadrilateral(): Estimate the probability that four points, chosen uniformly at random in the unit circle, form a concave (=nonconvex) quadrilateral. Estimated concave probability = 0.2944 Expected value is 0.29552. umbrella(): A person has XI umbrellas at home, and YI at the office. With probability P, it will be raining at any given time. If it is raining, the person takes an umbrella from one place to the other. How many walks will the person take before running out of umbrellas? Use graphics to display results. Graphics saved as "umbrella.png" umbrella(): A person has XI umbrellas at home, and YI at the office. With probability P, it will be raining at any given time. If it is raining, the person takes an umbrella from one place to the other. How many walks will the person take before running out of umbrellas? Use graphics to display results. Graphics saved as "umbrella.png" walk(): A pedestrian begins M blocks east and M blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the average wait for stop lights? Estimated waiting time = 0.7639 walk(): A pedestrian begins M blocks east and M blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the average wait for stop lights? Estimated waiting time = 1.2199 walk(): A pedestrian begins M blocks east and M blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the average wait for stop lights? Estimated waiting time = 1.7909 walk(): A pedestrian begins M blocks east and M blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the average wait for stop lights? Estimated waiting time = 2.5251 walk(): A pedestrian begins M blocks east and M blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the average wait for stop lights? Estimated waiting time = 4.0331 walk(): A pedestrian begins M blocks east and M blocks north of a destination. At each intersection, there is a stop light which is set randomly, and switches after 1 minute. Until reaching avenue 1 or street 1, the pedestrian always crosses the intersection in accordance with the stop light. Thereafter, the pedestrian must wait at each stop light encountered. What is the average wait for stop lights? Estimated waiting time = 5.5586 digital_dice_test(): Normal end of execution. 05-Jan-2023 18:08:31