74 Chapter 3. Expected values Problem PP61 Consider the random variable X in Problem PP41. 1. Compute the expected value, the variance and the standard deviation of X. Report values of X in the range A2:A5, the probabilities in B2:B5. The expected value in cell D2: = πππππ ππ·ππΆπ(π΄2: π΄5; π΅2: π΅5). The variance in cell D3: = πππππ ππ·ππΆπ(π΄2: π΄5; π΄2: π΄5; π΅2: π΅5) − π·2 ∗ π·2. The standard deviation in cell D4: = πππ π(π·3). Answer: πΈ(π) = 2.05 πππ¦π , ππ2 = 0.7475 πππ¦π 2 , ππ = 0.8646 πππ¦π ; 2. Generate 500 values of X: sample size 1 to 500 in the range A2:A501, random numbers in the range B2:B501, the values of X in the range C2:C501. Example for cell C2: = πΌπΉ (π΅2 < 0.3; 1; πΌπΉ(π΅2 < 0.7; 2; πΌπΉ(π΅2 < 0.95; 3; 4))). In column D compute the moving average as the sample size increases. Example for cell D2: = π΄ππΈπ π΄πΊπΈ(πΆ$2: πΆ2). Drag cell D2 to cell D501 (the average is computed for all samples of size 1, 2, …,500). In a similar way compute the sample variances in column E. Example for cell E3: = ππ΄π . π(πΆ$2: πΆ3). Compute the sample standard deviations in column F. Example for cell F3: = πππ·πΈπ. π(πΆ$2: πΆ3) or = πππ π(πΈ3); 3. Make a graphical representation of the sample means as a function of the sample size by using the Scatter with straight lines option. Also draw a horizontal line for the expected value. To construct a horizontal line, add a Series to the graph. The series is constructed as follows: the values 1 and 500 in successive cells, say H13:H14, the expected value 2.05 in cells I13 and I14; 4. Construct graphical representations for the variance and the standard deviation similar to Step 3. Repeat the simulation several times (key F9). Assignment PA61 Consider Assignment PA41. Compute the expected value, the variance and the standard deviation of Y. Simulate 500 rolls of the dice and compute sample means, variances and standard deviations of Y as a function of the number of rolls. Make graphical representations as in Steps 3 and 4 above. 75 Problem PP62 Consider the random variable X in Problem PP41. 1. Use Excel to compute the median and the coefficient of skewness of X. Use as coefficient of skewness π3 ⁄π 3 where π3 = ∑ππ=1(π₯π − π)3 ∗ π(π₯π ) for a discrete random variable X that can take on the values π₯1 , π₯2 , … , π₯π , π is the expected value of X and π is the standard deviation. Report the values of X in the range A2:A5, the corresponding probabilities in the range B2:B5. Compute the expected value of X in cell E2, the standard deviation in cell E5 and the terms (π₯π − π)3 in the range C2:C5. Example for cell C2: = ππππΈπ (π΄2 − πΈ$2; 3) and likewise for cells C3:C5. Compute the coefficient of skewness in cell E7: = πππππ ππ·ππΆπ(πΆ2: πΆ5; π΅2: π΅5)⁄ππππΈπ (πΈ5; 3). Answer: ππππππ = 2, π πππ€πππ π = 0.3679; 2. Generate 500 values of X: sample size 1 to 500 in the range A2:A501, random numbers in B2:B501, values of X in C2:C501 (see Problem PP61). Compute the sample medians in column D. Example for cell D2: = ππΈπ·πΌπ΄π(πΆ$2: πΆ2) and drag to cell D501 (the median is computed for all samples of size 1, 2, …,500). Compute all coefficients of sample skewness in column E. Example for cell E4: = ππΎπΈπ(πΆ$2: πΆ4) and drag to cell E501; 3. Make a graphical representation of the sample medians as a function of the sample size (see Problem PP61). Draw a horizontal line for the median of X in the same graph. Similarly make a graphical representation for the skewness. Repeat the simulation several times (key F9). Assignment PA62 Consider Assignment PA41. Compute the median and the coefficient of skewness of Y. Simulate 500 rolls of the dice and compute sample medians and coefficients of skewness as a function of the number of rolls. Make graphical representations as in Step 3 above. 76 Problem PP63 Consider the random variable X in Problem PP41. Two measures of the quality of the deliveries are considered: π1 = 12 − 2 ∗ π and π2 = 10 − (π − 1)2 . 1. Derive the pmf of π1 and π2 . Answer: π1 π(π1 ) 4 0.05 6 0.25 8 0.40 10 0.30 π2 π(π2 ) 1 0.05 6 0.25 9 0.40 10 0.30 2. Compute the expected value, the variance and the coefficient of skewness cos of π1 and π2 using the pmf’s derived in Step 1 (see Problems PP61 and PP62). Compute the expected value, the variance and the coefficient of skewness of π1 using the expected value, the variance and the coefficient of skewness of X and the fact that π1 is a linear function of X. Answer: πΈ(π1 ) = 7.9, ππ21 = 2.99, πππ (π1 ) = −0.3679; πΈ(π2 ) = 8.15, ππ22 = 5.0275, πππ (π2 ) = −1.6514; 3. Simulate the problem as follows: sample size 1 to 500 in cells A2:A501, random numbers in cells B2:B501, values of X in cells C2:C501 (see Problem PP61), values of π1 in cells D2:D501 using the values of X in column C, values of π2 in cells E2:E501, sample means of π1 in cells F2:F501 as a function of the sample size (as in Problem PP61), sample variances of π1 in cells G3:G501, coefficients of skewness of π1 in cells H4:H501, sample means of π2 in cells I2:I501, sample variances of π2 in cells J3:J501, coefficients of skewness of π2 in cells K4:K501; 4. Make graphical representations of the sample means of π1 and π2 as a function of the sample size by using the Insert\Scatter\Scatter with straight lines option. Also draw horizontal lines for the expected values of π1 and π2 . Construct similar graphs for the variances and the coefficients of skewness. Repeat the simulation several times (key F9). Assignment PA63 Repeat Steps 1 to 4 above for the quality measure π3 = 10 − 2 ∗ √π − 1. 77 Problem PP64 Consider the random variable X in Problem PP41. Assume the possible values of X remain fixed, but you can change the probabilities. 1. Intuitively, which pmf would you consider to have the largest possible variance? Answer: X p(x) 1 0.5 2 0 3 0 4 0.5 2. Check your answer in Step 1 by using the Solver of Excel as follows: the values of X in cells A2:A5, the probabilities in B2:B5, the sum of the probabilities in cell B6: = πππ(π΅2: π΅5). Compute the expected value of X in cell A7: = πππππ ππ·ππΆπ(π΄2: π΄5; π΅2: π΅5). Compute the variance of X in cell A8: = πππππ ππ·ππΆπ(π΄2: π΄5; π΄2: π΄5; π΅2: π΅5) − π΄7 ∗ π΄7. Use the Solver to maximize cell A8, allowing cells B2:B5 to change. Add the restrictions that all probabilities must be nonnegative and that their sum must equal 1; 3. Use the Solver as in Step 2 but add the restriction that the expected value of X can be at most 2. Answer: x p(x) 1 2/3 2 0 3 0 4 1/3 Assignment PA64 Consider the experiment of rolling a (false) die. Intuitively, which pmf would you expect to have maximal variance if the probability of each outcome should be at least equal to 0.1. Verify your answer by using the Solver of Excel. Assume you would like to maximize the expected value of the outcome of rolling a (false) die. How should you select the probabilities when all probabilities must equal at least .1 and the variance of the outcome must be the same as the variance of the outcome of a fair die. Use the Solver to solve this problem. 78 Problem PP65 Consider Problem PP42. 1. Compute the expected value, the variance and the standard deviation of the score X of player A. Answer: πΈ(π) = 161⁄36, ππ2 = 1.9715, ππ = 1.4041; 2. Simulate the game over 1000 lines as in Problem PP42. Use the simulated data to compute an estimate of the expected value, the variance and the standard deviation of the score of player A. Compare the results to the exact values in Step 1. Assignment PA65 Consider Assignment PA42. Compute the expected value, the variance and the standard deviation of the ratio of the larger of both outcomes to the smaller one. Compute estimated values of these parameters using a simulation over 2000 lines. Compare the estimated values to the exact population values. 79 Problem PP66 1. Consider Problem PP44. Compute the expected value, the variance and the standard deviation of the variable X. Answer: πΈ(π) = 4.75, ππ2 = 1.9097, ππ = 1.3819 ; 2. Simulate the game over 1000 lines as in Problem PP44. Compute an estimate of the expected value, the variance and the standard deviation of X. Compare the results to the exact values in Step 1. Assignment PA66 Consider Assignment PA44. Compute the expected value, the variance and the standard deviation of the random variable X. Compute estimated values of these parameters using a simulation over 1000 lines. 80 Problem PP67 Consider Problem PP46. 1. It is not obvious to intuitively estimate the exact expected value of X. Make a guess anyway; 2. Compute the expected value, the variance and the standard deviation of the variable X. Answer: πΈ(π) = 1.75, ππ2 = 0.7875, ππ = 0.8874; 3. Compute the expected value, the variance and the standard deviation of the variable Y. Answer: πΈ(π) = 3.5, ππ2 = 1.05, ππ = 1.0247; 4. Simulate the game over 1000 lines as in Problem PP46. Compute an estimate of the expected value, the variance and the standard deviation of variables X and Y. Compare the results to the exact values in Step 2 and 3. Assignment PA67 Consider Assignment PA46. Compute the expected value, the variance and the standard deviation of the random variable X. Compute estimated values of these parameters using a simulation over 1000 lines. 81 Problem PP68 Consider Problem PP47. 1. Compute the expected value, the variance and the standard deviation of the amount received. Answer: πΈ(π) = 2.999, ππ2 = 5.241, ππ = 2.2893; 2. Simulate the process over 1000 lines as in Problem PP47. Compute an estimate of the expected value, the variance and the standard deviation of the amount received. Compare the results to the exact values in Step 1. Assignment PA68 Consider Assignment PA47. Compute the expected value, the variance and the standard deviation of the amount received. Compute estimated values of these parameters using a simulation over 1000 lines. Compare the estimated values to the exact population values. 82 Problem PP69 Consider Problem PP48. 1. Compute the expected value, the variance and the standard deviation of the variable X. Answer: πΈ(π) = 4.2253, ππ2 = 1.5264, ππ = 1.2355; 2. Simulate the process over 1000 lines as in Problem PP48. Compute an estimate of the expected value, the variance and the standard deviation of X. Compare the results to the exact values in Step 1. Assignment PA69 Consider Assignment PA48. Compute the expected value, the variance and the standard deviation of X. Compute estimated values of these parameters using a simulation over 1000 lines. Compare the estimated values to the exact population values. 83 Problem PP70 Consider Problem PP49. 1. Compute the expected value, the variance and the standard deviation of the position X of the drunk after 4 minutes of walking. Answer: πΈ(π) = 2, ππ2 = 3, ππ = 1.732; 2. Simulate the process over 1000 lines as in Problem PP49. Compute an estimate of the expected value, the variance and the standard deviation of the position of the drunk. Compare the results to the exact values in Step 1. Assignment PA70 Consider Assignment PA49. Compute the expected value, the variance and the standard deviation of the position of the drunk. Compute estimated values of these parameters using a simulation over 1000 lines. 84 Problem PP71 Consider Problem PP50. 1. Compute the expected value, the variance and the standard deviation of demand D. Answer: πΈ(π·) = 92.5, ππ·2 = 178.75, ππ· = 13.3697; 2. Compute the expected value, the variance and the standard deviation of the profit P. Answer: πΈ(π) = 4700, ππ2 = 90000, ππ = 300; 3. Simulate 1000 demands as in Problem PP50. Compute an estimate of the expected value, the variance and the standard deviation of demand and profit. Compare the results to the exact values in Step 1 and 2. Assignment PA71 Consider Assignment PA50. Compute the expected value, the variance and the standard deviation of the quality measure Q. Compute estimated values of these parameters using a simulation over 1000 lines. 85 Problem PP72 Consider Problem PP52. 1. Compute the expected value, the variance and the standard deviation of the second integer X. Answer: πΈ(π) = 7.75, ππ2 = 5.1875, ππ = 2.2776; 2. Simulate 1000 values of X as in Problem PP52. Compute an estimate of the expected value, the variance and the standard deviation of X. Compare the results to the exact values in Step 1. Assignment PA72 Consider Assignment PA52. Compute the expected value, the variance and the standard deviation of the second number X. Compute estimated values of these parameters using a simulation over 1000 lines. 86 Problem PP73 Consider Problem PP54. 1. Compute the expected value, the variance and the standard deviation of your gain X. Answer: πΈ(π) = 6, ππ2 = 58, ππ = 7.6158; 2. Simulate the experiment 1000 times as in Problem PP54. Compute an estimate of the expected value, the variance and the standard deviation of your gain. Compare the results to the exact values in Step 1. Assignment PA73 Consider the problem above but you toss the coin at most ten times. When no “H” is tossed after 10 tosses, you win € 211 = 2048. Compute the expected value, the variance and the standard deviation of your gain. Show that the expected value equals the maximal number of tosses plus 2. Compute estimated values of these parameters using a simulation over 1000 lines. Notice the (often) poor estimates for the variance (and even the expected value) of the gain (intuitive explanation?). Compare the results to the case of tossing the coin at most four times. 87 Problem PP74 Consider Problem PP55. 1. Compute the expected value, the variance and the standard deviation of X and Y. Answer: πΈ(π) = 11⁄3 , ππ2 = 8⁄9 , ππ = √8⁄9 πΈ(π) = 10⁄3 , ππ2 = 32⁄9 , ππ = √32⁄9; 2. Generate 500 values of X and Y as in Problem PP55. Make a graphical representation of the sample means of X and Y as a function of the sample size by using Insert\Scatter\Scatter with straight lines (see Problem PP61). Include horizontal lines for the expected values of X and Y. Do likewise for the sample variances. Assignment PA74 Consider Assignment PA55. Apply Steps 1 and 2 above to the random variables X and Y. 88 Problem PP75 Consider Problem PP56. 1. Compute the expected value, the variance and the standard deviation of X, Y and V. Answer: πΈ(π) = 1⁄2 , ππ2 = 1⁄12 , ππ = √1⁄12 πΈ(π) = 2⁄3 , ππ2 = 1⁄18 , ππ = √1⁄18 πΈ(π) = 1⁄3 , ππ2 = 4⁄45 , ππ = √4⁄45; 2. Generate 500 values of X, Y and V. Make a graphical representation of the sample means of X, Y and V as a function of the sample size (see Problem PP61). Include horizontal lines for the expected values of X, Y, and V. Do likewise for the sample variances. Assignment PA75 Consider Assignment PA56. Apply Steps 1 and 2 above to the random variables X, Y and V. 89 Problem PP76 Consider Problem PP58. 1. Compute the expected value, the variance and the standard deviation of the circumference Y and the area W. Answer: πΈ(π) = 3π, ππ2 = π 2 ⁄3 , ππ = π⁄√3; 7 34 34 πΈ(π) = 3 π, ππ2 = 45 π 2 , ππ = √45 π; 2. Generate 500 values of Y and W as in Problem PP58. Make a graphical representation of the sample means of X and W as a function of the sample size (see Problem PP61). Include horizontal lines for the expected values of Y and W. Do likewise for the sample variances. Assignment PA76 The side of a cube is a random number between 0 and 1. Derive the pdf of the area Y and the volume W of the cube. Compute the expected value and the variance of Y? What is the expected value and the variance of W? Generate 500 values of Y and W. Make a graphical representation of the sample means of X and W as a function of the sample size (see Problem PP61). Include horizontal lines for the expected values of Y and W. Do likewise for the sample variances. 90 Problem PP77 1. A random variable X has pdf π(π₯) = 1, 0 < π₯ < 1. Verify that the expected value of π = 1⁄π equals +∞ (or, does not exist); 2. Simulate the problem: generate 2000 values of X in the range A2:A2001 and the corresponding values of Y in the range B2:B2001. Compute the sample means of the Y-values as a function of the sample size in cells C2:C2001. Make a graphical representation of the evolution of the sample means as a function of the sample size (see Problem PP61). Repeat your simulation a number of times. Discuss your findings in view of your answer in Step 1. Assignment PA77 Repeat Steps 1 and 2 above replacing the expected value (and sample mean) by the median. Compare with the result for the mean in Step 2 above. 91 Problem PP78 Consider the problem described in PP51. 1. Let X be the number of rounds played. Possible values of X are 1, 2, …,r. Compute the expected number of rounds that will be played as a function of N and r. 1 Answer: π [1 − (1 − π)π ] where π = π ∗ (1⁄2)π−1 ; 2. Compute using Excel the expected values derived in Step 1 for π = 5 and π = 3, 4, … , 25; 3. Simulate the problem for π = 5 and π = 5. The results of the five tosses of round 1 in cells A2:A6: = πΌπΉ(π π΄ππ·( ) < .5; "π»";"π"). Likewise for the (possible) next rounds in columns B, C, D, E. In cell A7, we mark 1 if a victim has been found in the first round: = πΌπΉ(ππ (πΆπππππΌπΉ(π΄2: π΄6; "π»") = 1; πΆπππππΌπΉ(π΄2: π΄6; "π»") = 4); 1; ""). Mark a 2, 3, 4 in cells B7, C7, D7 in a similar way for the next rounds. Mark a 5 in cell E7 when the range A7:D7 is empty, otherwise leave cell E7 empty. The number of rounds played can now be computed in cell H2: = ππΌπ(π΄7: πΈ7). Use the TABLE option to generate the process 1000 times in the range H2:H1001. Compute the average number of rounds over the 1000 processes. Repeat the simulation a number of times and compare the average number of rounds with the expected value computed in Step 2 for π = 5 and π = 5. Assignment PA78 Three persons A, B and C order a coffee. The cost of a coffee is € 2. They then roll a die and the total bill of € 6 is paid by the person(s) who gets the smallest outcome on the dice. When the smallest outcome is not unique, the bill is evenly split among those that roll the smallest outcome. Derive the pmf of the amount that person A will have to pay. Intuitively what do you think is the expected value of the amount that person A will have to pay? Compute the expected value using the pmf derived. Simulate this process over 1000 lines and compute the average amount that person A has to pay. Compare the average value with the expected value. 92 Problem PP79 400 dice are rolled. Player P1 then rolls one die. Assume the face of P1’s die is π₯. P1 receives all dice with a face value of at most π₯ − 2. Next a second player P2 rolls a die. Assume the face value of P2’s die is y. P2 receives all the dice not received by P1 and with face value at most y. 1. Take randomly one die from the 400 dice. Compute the probability that P1 (P2) will receive that die. Answer: π(π1) = 10⁄36, π(π2) = 19⁄54; 2. How many dice does P1 (P2) expect to receive? Answer: πΈ(π1) = 1000⁄9 = 111.111, πΈ(π2) = 3800⁄27 = 140.7407; 3. Simulate the problem. Report the outcome of 400 dice in the range A2:A401, the outcome of P1’s roll in cell B2. In the range C2:C401, mark 1 when P1 receives the die in the corresponding cell in column A. Report the outcome of P2’s roll in cell D2. In cells E2:E401, mark 1 when P2 receives the die in the corresponding cell in column A. Example for cell E2: = πΌπΉ(π΄ππ·($π·$2 ≥ π΄2; πΆ2 = 0); 1; 0). Compute the number of dice received by P1 in cell G2, the number of dice received by P2 in cell H2. Use the TABLE option to repeat the process 1000 times in columns G and H. Compute in cell J2 the average number of dice received by P1, in cell K2 the average number received by P2. Compare the average numbers of dice received by P1 and P2 with the expected values computed in Step 2. Assignment PA79 Consider Problem PP19. Assume πΎ = 160. How many coins does P5 expect to receive? How many coins are expected to be left after 5 rounds? Simulate the problem using the TABLE option over 1000 lines. Derive estimates of the expected number of coins received by P5 and the expected number left after 5 rounds. Compare the estimates with the expected values. 93 Problem PP80 Every day a bus drives from point A to point B over a distance of 100 km. The bus may break down. A repair station is available at A and B and a third station has to be built between A and B, say at point C. When the bus breaks down, the bus is towed to the nearest repair station. The objective is to build the third station in such a way that the expected towing distance is minimal. Let Y represent the distance in km between A and the point where the bus breaks down. Assume the pdf of Y equals π(π¦) = 1⁄100 , 0 < π¦ < 100 1. Where do you intuitively expect the repair station should be built? What do you think the expected towing distance to be for this location? 2. Compute the expected towing distance as a function of x, with x the distance from location A to location C. Minimize this expected value with respect to x. Compute the expected towing distance for this optimal location. Answer: πΈ(π‘ππ€πππ πππ π‘ππππ) = 1⁄100 ∗ (π₯ 2 ⁄2 − 50π₯ + 2500), minimal at π₯ = 50, expected towing distance = 12.5 km; 3. Simulate the problem. Report any value for x in cell B1, the distance from A to C, say 70. Generate values of Y in cells A2:A1001: = 100 ∗ π π΄ππ·( ). Compute the towing distance in B2:B1001 when the third station is located at C. Example for cell B2: = πΌπΉ (π΄2 < π΅$1 2 ; π΄2; πΌπΉ (π΄2 < π΅$1; π΅$1 − π΄2; πΌπΉ (π΄2 < π΅$1 2 + 50; π΄2 − π΅$1; 100 − π΄2))). Compute the average value of cells B2:B1001. Change the value in cell B1 to different values between 0 and 100. For the value 50, compare the average towing distance with the expected towing distance computed in Step 2. Assignment PA80 Change the pdf of Y in the problem above to π(π¦) = π¦⁄5000, 0 < π¦ < 100. Intuitively, what do you think will happen with the location of repair station C compared to the location above? Will the optimal value of x increase/decrease/remain unchanged? Why? What will happen to the expected towing distance? Will it increase/decrease/remain unchanged? Why? Repeat Steps 2 and 3 above for the new pdf of Y (to derive the optimal value of x from the expected towing distance, use the Solver of Excel). 94 Problem PP81 A large number N of people will be tested for a virus by taking a blood test. All individuals can be tested separately. In that case, N blood tests have to be conducted. The N people can also be divided randomly into N k groups of size π ≥ 2 (assume for simplicity N k to be integer). A mixture of the blood of k people in a group is tested. If no virus is found, nobody in the group carries the virus and just one test suffices for that group. If the virus is found, all k individuals of the group will be tested, hence π + 1 tests have to be conducted for that group. Assume a probability p that a person carries the virus (and π = 1 − π that he/she does not). 1. What is the probability that only one test is needed for a group of k people? Answer: (1 − π)π ; 2. What is the probability that π + 1 tests will be needed for a group of k people? Answer: 1 − (1 − π)π ; 3. Compute the expected number of tests that will be needed for a group of k people as a function of k. Answer: π + 1 − π ∗ (1 − π)π ; 4. Compute the expected number of tests that will have to be performed for all N people as a function of k. Answer: (π⁄π) ∗ [π + 1 − π ∗ (1 − π)π ]; 5. Let π = 4800 and π = 0.001. Use the Solver to compute an optimal value of k. How many tests do we expect to save, as a percentage, when comparing this approach to the case of testing all individuals? Answer: π ∗ = 32, πΈ(ππ’ππππ ππ π‘ππ π‘π ) = 301.243, πΈ(π ππ£πππ) = 93.724%. Assignment PA81 In the land of Nirwana all company workers get a day off when at least one of the company workers has his/her birthday. All other days of the year they are active (have to work). Assume no leap year in Nirwana so that every year has 365 days. People are randomly hired by companies and births are independent with equal probabilities for all days of the year. When a company has x workers, what is the probability that the workers will be active on a random day of the year? What is the probability that all workers will get a day off on a random day of the year? What is the expected number of active workers on a random day for a company with x workers? What is the expected number of active workers for the whole year? Use the Solver to compute the number of workers x the company should hire in order to maximize the expected number of active workers for the whole year. 95 Problem PP82 John remembers having agreed to meet his girlfriend Mary at some time between 6 pm and 7 pm but he does not remember the exact time. Therefore he assumes the minutes Mary will arrive after 6 pm to be a random variable X with pdf π(π₯) = 1⁄60, 0 < π₯ < 60. 1. Assume John decides to go to the meeting place at 6.15 pm. Compute his expected waiting time W. Answer: 135/8 minutes; 2. John starts worrying about his girlfriend having to wait. Therefore he assumes a penalty π2 when his girlfriend has to wait g minutes and a penalty b when he has to wait b minutes. Compute the expected penalty when he decides to go to the meeting place at 6.15 pm. Answer: 35.625; 3. Under the assumptions in Step 2, at what time should John go to the meeting place when he decides to minimize the expected penalty? Hint: derive the expected penalty as a function of his arrival time Y (minutes after 6 pm) and minimize this expected penalty (you can use the Solver). Answer: πΈ(ππππππ‘π¦) = 1⁄360 ∗ [2π¦ 3 + 3 ∗ (60 − π¦)2 ] π¦∗ = −1+√241 2 = 7.262 minutes after 6 pm; 4. Simulate the problem. Generate arrival times of Mary in the range A2:A1001: = 60 ∗ π π΄ππ·( ). Put the value 15 (arrival in minutes after 6 pm of John) in cells B1 and C1. Compute John’s waiting time in cells B2:B1001 for the arrival times of Mary in column A. Example for cell B2: = πΌπΉ(π΄2 < π΅$1; 0; π΄2 − π΅$1). Compute the penalty in cells C2:C1001: = πΌπΉ(π΄2 < πΆ$1; ππππΈπ (πΆ$1 − π΄2; 2); π΄2 − πΆ$1). Compute John’s average waiting time from column B and the average penalty from column C. Compare those values with the expected values computed in Steps 1 and 2. Change the value 15 in cell C1 to John’s optimal arrival time (minutes after 6 pm) and compare the average penalty in column C to the expected penalty computed in Step 3. Assignment PA82 Assume the pdf of Mary’ arrival time (in minutes after 6 pm) is π(π₯) = π₯⁄1800, 0 < π₯ < 60. When John arrives at 6.15 pm, do you think his expected waiting time will increase/decrease/remain unchanged compared to the solution in Step 1 above? Why? Compute his expected waiting time. Assume a penalty function as in Step 2. Compute the expected penalty when he arrives at 6.15 pm. Derive his optimal arrival time when his objective is to minimize the expected penalty. Simulate the problem similar to Step 4. 96 Problem PP83 A random variable X has pdf π(π₯) = 1⁄100 , 0 < π₯ < 100. You may choose any positive number c. 1. When a realization of X is smaller than c, your gain π1 is 0. When X is greater or equal to c, your gain π1 is c. Compute your expected gain. Which value of c results in maximal expected gain? Compute the maximal expected gain. Answer: π = 50, πΈ(π1 ) = 25; 2. As in Step 1 but the gain π2 equals –c when X is smaller than c, equals c when X is greater or equal to c. Answer: π = 25, πΈ(π2 ) = 25⁄2; 3. As in Step 1 but the gain π3 equals −π 2 when X is smaller than c, equals π 2 when X is greater or equal to c. Answer: π = 100⁄3 , πΈ(π3 ) = 370.37; 4. Simulate the problem. Generate values of X in the range A3:A1002. Report arbitrary positive numbers as values of c in B2, C2 and D2. Compute values of π1 , π2 and π3 in B3:B1002, C3:C1002 and D3:D1002 using the value of c in B2, C2 and D2 and the values of X in column A. Compute the average gains derived from columns B, C and D. Change the values of c to the values derived in Step 1, Step 2 and Step 3. Compare the average gains to the maximal expected gains in Steps 1 to 3. Assignment PA83 Apply Steps 1 to 4 for a random variable X with pdf 1 1 π(π₯) = 50 ∗ π −50π₯ , π₯ > 0 97 Problem PP84 A shop sells a particular type of deli meat which spoils easily, hence can only be sold during one day. Assume demand for that type of meat to be a random variable X (unit is kg) with pdf π(π₯) = 1⁄(π − π) , π < π₯ < π (a and b are known constants). The shop owner has to decide on the amount of meat to stock at the beginning of the day (no additional meat can be ordered later in the day). He buys the meat at a price of € q/kg and sells it at a price of € s/kg (π > π). Units not sold at the end of the day cannot be sold later. 1. Derive the expected daily profit of the shop when i kg of the deli meat (π < π < π) is available at the start of the day. Answer: 1 π {[ππ − π ∗ (π − π)] ∗ π − ∗ (π 2 − π2 )}; (π−π) 2 2. Compute in Excel the expected profit for π = 10, π = 20, π = 20, π = 25 and values of i equal to 10, 10.25, …, 20. Graph the expected profit and check the value of i for which the expected value is maximal; 3. Derive the value of i that maximizes the expected profit derived in Step 1. Compare this value to the value derived in Step 2. 1 Answer: π ∗ [(π − π) ∗ π + ππ]; 4. Simulate the problem for the parameter values given in Step 2: generate 1000 demands for the product in the range A3:A1002. Report a value for i in cell B2, e.g. 15. Compute profits in cells B3:B1002 for the demands in column A and the value of i in cell B2. Compute the average profit from column B. Change the value of i to the optimal value derived in Step 3 and compare the average simulated profit to the expected profit. Assignment PA84 Repeat Steps 1 to 4 when the pdf of demand equals π(π₯) = π₯⁄150 , 10 < π₯ < 20. 98 Problem PP85 Consider Problem PP59. 1. Derive the expected length of the shortest piece. Answer: ¼; 2. Derive the expected length of the longest piece. Answer: ¾; 3. Derive the expected length of the difference in length between the longest and the shortest piece. Answer: ½; 4. Derive the expected value of the ratio of the length of the shortest to the length of the longest piece. Answer: 2 ∗ ππ2 − 1; 5. Derive the expected value of the ratio of the length of the longest to the length of the shortest piece. Answer: does not exist ( or +∞ ); 6. Simulate the problem as in Problem PP59. Compute average values of all the variables in Steps 1 to 5. Compare the average values to the expected values computed above. Assignment PA85 Consider the Assignment in Problem PP59. Compute the expected value of the difference in length between the left and the right piece. Compute the expected value of the ratio of the length of the left to the length of the right piece. Simulate the problem and compare average values derived from the simulation to the expected values. 99 Problem PP86 Two teams T1 and T2 compete in a best of seven series (the team that first wins four games is the winner). Assume the probability that T1 wins a game is constant and equal to p. A game always ends with a winner (no ties). 1. Derive the pmf of the number of games X that will be played to determine a winner as a function of p. Answer: X p(x) 4 4 π + (1 − π)4 5 4 ∗ π ∗ (1 − π) ∗ (3π2 − 3π + 1) 6 10 ∗ π ∗ (1 − π)2 ∗ (2π2 − 2π + 1) 2 7 20 ∗ π3 ∗ (1 − π)3 2. Compute the pmf derived in Step 1 for values of π = 0, 0.1, 0.2, … , 1 (use Excel); 3. Compute the expected value of the number of games that will be played as a function of π = 0, 0.1, 0.2, … , 1 (use Excel). Graph the expected number as a function of p; 4. Simulate this competition 1000 times as follows: report the probability p in cell E1, e.g. 0.5. Denote the winner of 7 games in cells A2.A8: = πΌπΉ(π π΄ππ·( ) < $πΈ$1; "π1";"π2"). In cells B5:B8 compute how many games are needed to determine the winner. Example for cell B5: = πΌπΉ(π΄ππ·(ππ΄π(πΆπππππΌπΉ(π΄$2: π΄5; "π1"); πΆπππππΌπΉ(π΄$2: π΄5; "π2")) = 4; ππ΄π(π΅$2: π΅5) = 0); 4; ""). Similarly for cells B7 to B9. Copy the number of games into cell D3: = ππ΄π(π΅5: π΅8). Use the TABLE-option to simulate the problem 1000 times in column D. Compute the average number of games and compare the average number to the expected value computed in Step 3. Assignment PA86 Repeat the problem above for the best of nine games. 100 Problem PP87 You play a game where the probability of winning is p. When you win, the pay-off is twice your bet. You can repeat the game and the probability of winning remains unchanged. You decide on the following betting strategy: you begin by betting € 1 and you double your bet as long as you lose, if you win you stop. If you can keep up this strategy, you will win € 1 eventually. For instance, when you lose three times in a row and win the fourth time your total betting amount is € 15 (=1+2+4+8) and you win € 16 (2*8). However you are a poor student and you have only € 56 in your pocket. So you adapt the above strategy as follows: you double the bet at most four times to € 16 and when you lose five times in a row you bet your remaining money (= € 25) and pray. Notice that your gain is € 1 when you win one of the first five games, that you lose € 6 when you lose the first five games and wins the sixth game and that you lose € 56 when you lose all six games. Call a complete game the above series of games until you either win or lose money. 1. Derive the pmf of the gain (loss) X of a complete game as a function of p. Answer: X p(x) 1 1 − (1 − π)5 -6 π ∗ (1 − π)5 -56 (1 − π)6 2. Compute the expected gain (loss) of a complete game as a function of p. Answer: 1 − (1 − π)5 ∗ (57 − 50π); 3. What is the expected value of a complete game for π = 18⁄37 (a common roulette value in casinos). Answer (rounded): -0.1668; 4. Use Excel to compute the expected value and the variance of the gain (loss) for π = 0, 0.1, … , 0.9, 1. Answer (rounded): p E(X) Var(X) 0 -56 0 .1 -29.71 786.72 .2 -14.40 617.73 .3 -6.06 334.88 .4 -1.88 144.83 .5 .6 0 50.53 0.72 13.53 .7 0.95 2.45 .8 0.99 0.22 .9 0.9999 0.004 1 1 0 5. Find the value of p for which the complete game breaks even (expected value = 0). Use the Solver to compute this value. Answer: π = 0.5; 6. Simulate the game as follows: report a value of p, say π = 18⁄37, in cell A2, put random numbers in the range A3:A8 for at most six games to be played. Assume you win when a random number is smaller than the value in cell A2. Compute your gains or losses in cells B3 to B8. Example: for the third game in cell B5: = πΌπΉ(ππ΄π(π΅$3: π΅4) = 1; ""; πΌπΉ(π΄5 < $π΄$2; 1; "")) and for the last game in cell B8: = πΌπΉ(ππ΄π(π΅$3: π΅7) = 1; "", πΌπΉ(π΄8 < $π΄$2; −6; −56)). Copy the gain/loss in cell E2: = πΌπΉ(ππ΄π(π΅3: π΅7) = 1; 1; π΅8). Use the TABLE-option to repeat the game 2000 times and compare the average gain/loss to the expected value computed in Step 2. 101 Assignment PA87 Assume in the above set up that you are somewhat better off financially. You play at most 7 times and if you lose 7 times in a row you stop and lose all your bets (€ 127). Perform the five steps above for this game. 102 Problem PP88 A total of 16 chairs numbered 1, 2, …, 16 are placed in a row. Eight people are randomly assigned a (different) chair. We use simulation to estimate the pmf and the expected value of the number of persons who will have a companion. A person has a companion if somebody is sitting on an adjoining chair, to the left and/or to the right. Work as follows: the numbers 1 to 16 in the range A2:A17 representing the chairs. Random numbers in the range B2:B17. Assume that a person is assigned to chair π − 1 in column A, row k, when the corresponding random number in column B, row k, is among the eight smallest numbers in the range B2:B17 (random assignment of persons to chairs). This is reported in column C, row k, by a “yes” when a person is assigned to chair π − 1 and by a “no” when the chair remains unassigned. The following array instruction will accomplish this for cell C2: = πΌπΉ(ππ (π΅2 = πππ΄πΏπΏ(π΅$2: π΅$17; {1,2,3,4,5,6,7,8})) = ππ ππΈ; "π¦ππ ";"ππ"). In column D, row k, we report 1 when a person is sitting on chair π − 1 and has a companion. Example for cell D3: = πΌπΉ(π΄ππ·(πΆ3 = "π¦ππ "; ππ (πΆ2 = "π¦ππ "; πΆ4 = "π¦ππ ")); 1; ""). In cell G2 count the number of persons with a companion: = πππ(π·2: π·17). Use the TABLE-option in Excel to simulate the sum in cell G2 1000 times. Derive an estimate of the pmf and an estimate of the expected value of the number of persons who have a companion. Assignment PA 88 Repeat the problem above when the chairs are placed around a round table so that chair 16 is next to chair 1. 103 Problem PP89 A rather large number of people all of different stature are randomly placed in a row. Select people from the row as follows: the first person in the row is selected, walk further along the row and add a person to the selection when he/she is taller than the ones selected so far. Repeat this process until you are at the end of the row of persons. Simulate the average number of people selected for a row of 50 people. Work as follows: the numbers 1 to 50 representing the 50 people in the range A2:A51. Assume person 1 is the smallest, person 2 the next smallest, etc. Order the 50 persons in column A randomly in column C using random numbers generated in cells B2 to B51. Example for cell C2 where we report the person who is placed first in the row: = πΌππ·πΈπ(π΄$2: π΄$51; ππ΄ππΆπ»(πππ΄πΏπΏ(π΅$2: π΅$51; π΄2); π΅$2: π΅$51; 0)) and similarly for the remaining persons in cells C3 to C51. Column D reports when a person is added to the selection as you walk along the row. Cell D2 equals cell C2, cell D3 contains the instruction = πΌπΉ(πΆ3 > πΆ2; πΆ3; π·2) and similarly for the remaining cells in column D. In cell G2 we compute the number of different persons selected in column D by the array instruction: = πππ(1⁄πΆπππππΌπΉ(π·2: π·51; π·2: π·51)). Use the TABLE-option to repeat cell G2 1000 times and compute the average number of different persons selected over the 1000 trials. Compare this value to the number ππ(50) + 1⁄100 + .577 which can be shown to give a close approximation to the expected value. Assignment PA89 Change the selection of people in the above scheme as follows: choose the first two persons in the row. Add a person to the selection when he/she is taller than the second tallest person selected so far (Rule 1). Repeat the simulation. Choose the first two persons in the row. Add a person to the selection when he/she is taller than the second tallest person met so far but smaller than the tallest person met so far (Rule 2). 104 Problem PP90 Consider Problem PP40. Assume the prizes are valued 1, 2, …,12 with a larger value meaning a more valuable prize. We determine through simulation the value of k for which the expected value of the prize received is maximal. Work as follows: the prizes numbered 1 to 12 in the range A3:A14. Arrange the prizes in random order in the range C3:C14 using random numbers generated in B3:B14. Example for cell C3 (the first prize in the list): = πΌππ·πΈπ(π΄$3: π΄$14; ππ΄ππΆπ»(πππ΄πΏπΏ(π΅$3: π΅$14; π΄3); π΅$3: π΅$14; 0)) and similarly for cells C4:C14. Report the values for π = 0, 1, 2, … , 11 in the range D2:O2. Compute the prize received in columns D to O for the values of k in row 2. Example for cell F8 (strategy π = 2): = πΌπΉ(π΄ππ·(ππ΄π(πΉ$3: πΉ7) = 0; πΆ8 > ππ΄π(πΆ$3: πΆ7)); πΆ8; ""). The cells in row 14 are slightly different. Example for cell F14: = πΌπΉ(ππ΄π(πΉ$3: πΉ13) = 0; $πΆ14; ""). In this way prizes have been determined for the list in column C and all values of k. To repeat the process the TABLE-option will be used. In the range Q2:AB2 we repeat the prizes for the different values of strategy k. Example for cell Q2: = ππ΄π(π·3: π·14) and similarly for cells R2 to AB2. Use the TABLE-option on columns P to AB to repeat the prize selection 1000 times. Compute the average value of the prize for all strategies in the range AD2:AO2. Graph the average prize as a function of the value of k. Does the seemingly optimal value of k differ from the optimal value of k in Problem PP40 where the probability of hitting the best prize was maximized? Assignment PA90 Consider Problem PP31. Assume 100 persons. Use simulation to approximate the average value of X, the number of common birthdays. To be precise X is defined as π2 + 2 ∗ π3 + 3 ∗ π4 + … where ππ is the number of days of the year having k persons with a common birthday (when three persons have the same birthday, count two common birthdays, when four persons have the same birthday, count three common birthdays, etc.). 105 Problem PP91 Let X be the number of rolls with a fair die needed to get the outcome 6. Let Y be the number of rolls needed to get two outcomes 6 successively. 1. Show that the expected value of X satisfies the equation πΈ(π) = 1⁄6 + 5⁄6 ∗ [πΈ(π) + 1] and solve for πΈ(π). Answer: πΈ(π) = 6; 2. Show that the expected value of Y satisfies the equation πΈ(π) = 5⁄6 ∗ [πΈ(π) + 1] + 1⁄6 ∗ [1⁄6 ∗ 2 + 5⁄6 ∗ [πΈ(π) + 2]] and solve for πΈ(π). Answer: πΈ(π) = 42; 3. Estimate the expected values in Steps 1 and 2 by simulation as follows: the numbers 1 to 1000 in the range A2:A1001. Report the result of 1000 rolls of the die in cells B2:B1001. Report 1 in column C when two successive Sixes have been rolled in column B. Example for cell C3: = πΌπΉ(π΄ππ·(π΅3 = 6; π΅2 = 6); 1; "") and similarly for cells C4:C1001 (we assume that two successive outcomes 6 will realize with no more than 1000 rolls, a reasonable assumption). Report the roll of the first 6 in cell E2 using the array instruction = πΌππ·πΈπ(π΄2: π΄1001, ππ΄ππΆπ»(6; π΅2: π΅1001; 0)) Report the roll when two successive sixes appear for the first time in cell F2 as the array instruction = πΌππ·πΈπ(π΄2: π΄1001, ππ΄ππΆπ»(1, πΆ2: πΆ1001,0)). Use the TABLE-option to repeat the values in cells E2 and F2 1000 times. Estimate the average number of rolls from the simulated data and compare to the exact values in Steps 1 and 2. Assignment PA91 Let X be the number of rolls needed to get successively the outcomes 5 or 6 or both. Derive the equation that πΈ(π) must satisfy (similar to Steps 1 and 2 above). Simulate the problem similar to the simulation in Step 3. 106 Problem PP92 Let π6 be the number of rolls with a die to obtain every outcome 1 to 6 at least once. To derive the expected value of π6, let π1 be the number of rolls further required to obtain all 6 outcomes after having obtained 5 different outcomes at least once. Clearly πΈ(π1 ) = 6 (see Problem PP91). Let π2 be the number of rolls further needed to obtain all six outcomes at least once after having obtained four different outcomes at least once. Argue that πΈ(π2 ) must satisfy πΈ(π2 ) = 4⁄6 ∗ [πΈ(π2 ) + 1] + 2⁄6 ∗ [πΈ(π1 ) + 1]. From this equation it follows that πΈ(π2 ) = 9. 1. Compute πΈ(π6 ) by continuing the reasoning above for π3 (number of further rolls needed after already having obtained three different outcomes), π4, etc.. Answer: πΈ(π6 ) = 14.7; 2. Estimate the expected number in Step 1 through simulation as follows: roll a die 100 times in the range A2:A101 (we assume that not more than 100 rolls will be needed to obtain all six outcomes at least once). Needing more than 100 rolls is indeed an extremely unlikely event and hence will be neglected. Compute in column B the number of different outcomes obtained so far. Example for cell B2, the array instruction: = πππ(1/πΆπππππΌπΉ(π΄$2: π΄2; π΄$2: π΄2)) and likewise for cells B3:B101. Count in cell E2 the number of rolls that is needed to obtain all six outcomes at least once by the array instruction: = ππΌπ(πΌπΉ(π΅$2: π΅$101 = 6; π ππ(π΅$2: π΅$101) − 1; "")). Use the TABLE-option to repeat the process 500 times. Estimate πΈ(π6 ) and compare to its exact value computed in Step 1. Assignment PA92 Roll six fair dice. Compute the exact probability that all six outcomes 1, 2, …, 6 are obtained. Estimate the probability by simulating the process a large number of times, say 2000 times and compare to the exact probability. Derive from the exact probability the expected number of rolls required with the six dice to obtain all six outcomes. Compute the probability that at most the expected number of rolls will be needed to roll all six outcomes. Estimate this probability by simulation and compare to the exact probability.