Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[20 points] Problem 2 Stella is very excited to have secured a professorship in the Computer Science department here at CU. She works hard, but

image text in transcribed

[20 points] Problem 2 Stella is very excited to have secured a professorship in the Computer Science department here at CU. She works hard, but has a problem finding her way around Boulder after leaving work. When she leaves work from the CU Engineering Center (E-Center), she must randomly choose a location on the map below and go there. Here are some rules governing her movements throughout the fair city of Boulder: When Stella is leaving one location, she randomly selects one of the available paths (denoted by arrows on the map), with equal probability, and goes to her next location. This includes back-tracking (when the arrows point in both directions). E.g. Stella could go from the Engineering Center to the Library, then directly back to the Engineering Center. Note that the path from the Library to her Home is a one way path. Once she goes home, she does not return to the library, or any other location on the map. She stays at home. Assume that all moves require the same amount of time. She cannot stay in one location, except for when she goes home. If she is not at her house, she must always move to another adjacent location. A "stop" is moving from one location to another. E.g. If Stella moves from the E-Center to the Library and then moves from the Library to the Gym, this is two "stops". Library Home E-Center Gym Pizza Coffee Part A: Stella is exhausted from a long day of researching whether P=NP so, naturally, she wants to go to the Coffee Shop (Coffee) to grab a coffee. Compute the probability that Stella goes to the Coffee shop at least once in either in her first, second, or third stop after leaving from the E Center. Calculate this by hand, showing your work in a markdown cell. You may leave answers as fractions or decimals. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part B: What is the probability that Stella gets to her house in exactly 2 stops after leaving the E-Center? Calculate this by hand, showing you work in a markdown cell(s). You may leave answers as fractions or decimels. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part C: What is the probability that Stella gets to her house in exactly 3 stops after leaving the E-Center? Calculate this by hand, showing you work in a markdown cell(s). You may leave answers as fractions or decimels. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part D: What is the probability that Stella gets to her house in exactly 4 stops after leaving the E-Center? What is the probability that she gets to her house in 4 or less stops? Calculate this by hand, showing you work in a markdown cell(s). You may leave answers as fractions or decimels. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part E: Write a Python simulation to confirm that your by-hand calculations in Part B, Part C, and Part D are correct. Don't worry about simulating Part A. Your simulation code should simulate Stella's movement after leaving the E-Center and end when she reaches home. You should run the simulation at least 2000 times and record how many stops it took Stella to get home on each run (in an array... don't print 2000 results). Then use that array to print the simulated probability of reaching home in 2 stops, 3 stops, 4 stops, and 4 or less stops. Then summarize your results in a markdown cell. Make sure to either comment your code, write exteremely readable code, or use a markdown cell to explain what your code does. Code that isn't immediately understandable with no additional explanation will lose you credit. Solution: # Your code here. Type Markdown and LaTex: a Part F: Make a frequency histogram of the number of stops it takes Stella to get home. Use a bin size of 1 and make sure to include all the data in the histogram (e.g. don't accidentally exclude data from your simulation by making too few bins). To make the graph more legible, make it a "bar" histogram with black edges. Look up the "histtype" and "ec" arguments to the histogram function in Matplotlib if you don't know how to do this. To further our goal of having this data look nice, make the figure 15 inches wide and 8 inches tall. Look up the "figsize" argument in Matplotlib if you don't know how to do this. Remember to include axis labels and a title. Make the graph nice and readable. Use the plt.show() function to avoid printing out extraneous information. # Your code here. Part G: Did you find it easier to calculate the probabilities by hand or simulate them with Python? What are some of the pro's and con's of simulating the probabilities versus calculating them by hand. Do you think it would be feasible to calculate the probabilities by hand for a graph that was much larger (eg. 100 Locations and 500 Paths)? Solution: [20 points] Problem 2 Stella is very excited to have secured a professorship in the Computer Science department here at CU. She works hard, but has a problem finding her way around Boulder after leaving work. When she leaves work from the CU Engineering Center (E-Center), she must randomly choose a location on the map below and go there. Here are some rules governing her movements throughout the fair city of Boulder: When Stella is leaving one location, she randomly selects one of the available paths (denoted by arrows on the map), with equal probability, and goes to her next location. This includes back-tracking (when the arrows point in both directions). E.g. Stella could go from the Engineering Center to the Library, then directly back to the Engineering Center. Note that the path from the Library to her Home is a one way path. Once she goes home, she does not return to the library, or any other location on the map. She stays at home. Assume that all moves require the same amount of time. She cannot stay in one location, except for when she goes home. If she is not at her house, she must always move to another adjacent location. A "stop" is moving from one location to another. E.g. If Stella moves from the E-Center to the Library and then moves from the Library to the Gym, this is two "stops". Library Home E-Center Gym Pizza Coffee Part A: Stella is exhausted from a long day of researching whether P=NP so, naturally, she wants to go to the Coffee Shop (Coffee) to grab a coffee. Compute the probability that Stella goes to the Coffee shop at least once in either in her first, second, or third stop after leaving from the E Center. Calculate this by hand, showing your work in a markdown cell. You may leave answers as fractions or decimals. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part B: What is the probability that Stella gets to her house in exactly 2 stops after leaving the E-Center? Calculate this by hand, showing you work in a markdown cell(s). You may leave answers as fractions or decimels. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part C: What is the probability that Stella gets to her house in exactly 3 stops after leaving the E-Center? Calculate this by hand, showing you work in a markdown cell(s). You may leave answers as fractions or decimels. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part D: What is the probability that Stella gets to her house in exactly 4 stops after leaving the E-Center? What is the probability that she gets to her house in 4 or less stops? Calculate this by hand, showing you work in a markdown cell(s). You may leave answers as fractions or decimels. You may use python code as a calculator, but may not simulate this probability, or use functions that do all of the work for you. Solution: Part E: Write a Python simulation to confirm that your by-hand calculations in Part B, Part C, and Part D are correct. Don't worry about simulating Part A. Your simulation code should simulate Stella's movement after leaving the E-Center and end when she reaches home. You should run the simulation at least 2000 times and record how many stops it took Stella to get home on each run (in an array... don't print 2000 results). Then use that array to print the simulated probability of reaching home in 2 stops, 3 stops, 4 stops, and 4 or less stops. Then summarize your results in a markdown cell. Make sure to either comment your code, write exteremely readable code, or use a markdown cell to explain what your code does. Code that isn't immediately understandable with no additional explanation will lose you credit. Solution: # Your code here. Type Markdown and LaTex: a Part F: Make a frequency histogram of the number of stops it takes Stella to get home. Use a bin size of 1 and make sure to include all the data in the histogram (e.g. don't accidentally exclude data from your simulation by making too few bins). To make the graph more legible, make it a "bar" histogram with black edges. Look up the "histtype" and "ec" arguments to the histogram function in Matplotlib if you don't know how to do this. To further our goal of having this data look nice, make the figure 15 inches wide and 8 inches tall. Look up the "figsize" argument in Matplotlib if you don't know how to do this. Remember to include axis labels and a title. Make the graph nice and readable. Use the plt.show() function to avoid printing out extraneous information. # Your code here. Part G: Did you find it easier to calculate the probabilities by hand or simulate them with Python? What are some of the pro's and con's of simulating the probabilities versus calculating them by hand. Do you think it would be feasible to calculate the probabilities by hand for a graph that was much larger (eg. 100 Locations and 500 Paths)? Solution

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

Step: 3

blur-text-image

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions