Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(Coding] Let's learn how to use Python and data to do approximate quantities that are hard to compute exactly! By the end of this, we'll
(Coding] Let's learn how to use Python and data to do approximate quantities that are hard to compute exactly! By the end of this, we'll see how long it actually takes to catchem all! You are given a file pokemon.txt which contains information about several (fictional) Pokemon, such as their encounter rate and catch rate. Write your code for the following parts in the provided file: pokemon.py. (a) Implement the function part_a. (b) Implement the function part_b. (c) Implement the function part_c. . (d) Implement the function part_d. 1 000 77.2464 11.5633 0.1029 0.9338 2 01 O 2.5648 30.6601 0.0762 0.8374 3020 63.5480 0.0396 0.0916 0.9689 4 03 0 75.0060 7.1783 0.1117 0.7685 5 04 050.1014 16.7462 0.0962 0.6908 6 05 0 22.8673 9.4811 0.0957 0.7622 7 06 1 20.2073 12.7925 0.1079 0.6988 8 07 0 76.1728 3.4514 0.1009 0.9418 9 08 0 17.3265 24.9829 0.1101 0.6759 10 09 1 9.2898 12.5378 0.1068 0.8729 4 5 def part_d(filename:str='data/pokemon.txt', ntrials:int=5000): 7 3 Suppose you are walking around the wild grass, and you wonder: how many encounters do you expect to make until you CATCH each Pokemon (at least) once? 0 1 2 3 4 :param filename: The path to the csv as described in the pset. :param ntrials: How many simulations to run. :return: The (simulated) average number of ENCOUNTERS you expect to make, until you CATCH each Pokemon (at least) once. 5 5 7 3 Hint(s): 1. You only need to use two of the columns for this part! 2. You may want to use np.random.choice(...) with the parameter a being np.arange(...) and the parameter p being the data column! 3. You may want to use np.random.rand (...). 3 1 2 3 4 5 data = np.genfromtxt(filename)[:, -2:] n_pokemon data.shape [0] def sim_one(): III!!! 5 7 3 This is a nested function only accessible by parent part_d, which we're in now. You may want to implement this function! IIIIII pass pass # TODO: Your code here (10-20 lines) 3 11 2 3 4 if 5 5 7 3 == __name__ !__main__': # You can test out things here. Feel free to write anything below. print(part_a()) print(part_b()) print(part_c()) print(part_d()) (Coding] Let's learn how to use Python and data to do approximate quantities that are hard to compute exactly! By the end of this, we'll see how long it actually takes to catchem all! You are given a file pokemon.txt which contains information about several (fictional) Pokemon, such as their encounter rate and catch rate. Write your code for the following parts in the provided file: pokemon.py. (a) Implement the function part_a. (b) Implement the function part_b. (c) Implement the function part_c. . (d) Implement the function part_d. 1 000 77.2464 11.5633 0.1029 0.9338 2 01 O 2.5648 30.6601 0.0762 0.8374 3020 63.5480 0.0396 0.0916 0.9689 4 03 0 75.0060 7.1783 0.1117 0.7685 5 04 050.1014 16.7462 0.0962 0.6908 6 05 0 22.8673 9.4811 0.0957 0.7622 7 06 1 20.2073 12.7925 0.1079 0.6988 8 07 0 76.1728 3.4514 0.1009 0.9418 9 08 0 17.3265 24.9829 0.1101 0.6759 10 09 1 9.2898 12.5378 0.1068 0.8729 4 5 def part_d(filename:str='data/pokemon.txt', ntrials:int=5000): 7 3 Suppose you are walking around the wild grass, and you wonder: how many encounters do you expect to make until you CATCH each Pokemon (at least) once? 0 1 2 3 4 :param filename: The path to the csv as described in the pset. :param ntrials: How many simulations to run. :return: The (simulated) average number of ENCOUNTERS you expect to make, until you CATCH each Pokemon (at least) once. 5 5 7 3 Hint(s): 1. You only need to use two of the columns for this part! 2. You may want to use np.random.choice(...) with the parameter a being np.arange(...) and the parameter p being the data column! 3. You may want to use np.random.rand (...). 3 1 2 3 4 5 data = np.genfromtxt(filename)[:, -2:] n_pokemon data.shape [0] def sim_one(): III!!! 5 7 3 This is a nested function only accessible by parent part_d, which we're in now. You may want to implement this function! IIIIII pass pass # TODO: Your code here (10-20 lines) 3 11 2 3 4 if 5 5 7 3 == __name__ !__main__': # You can test out things here. Feel free to write anything below. print(part_a()) print(part_b()) print(part_c()) print(part_d())
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started