Starting from:

$24.99

CS115 Lab 10-Plotting, Random Walk Simulation Solution

Lab Guide 10A

Lab Objectives: Plotting, Random Walk Simulation

1. Plot the function f(x) in the interval (−𝜋, 𝜋) with interval of 0.01, up to the sum of 2, 4 and 13 terms on the same plot with different colors.


2. An experiment measures and writes the penetration depth of a seed (d) every week for 15 weeks in a file called ‘seed.txt’. The results are as follows:
8 20 31 42 55 65 77 88 95 97 89 72 68 53 44

Write the script that will read the above data from ‘seed.txt’ file and produce plots of the weeks vs. the depth of the seeds. All formatting should be arranged according to the figure below.




3. Download the classes: Location, Field, Drunk and the script Lab10A_Q3.py from Moodle. Using these classes, complete the following:
a. Create a subclass of Drunk, EastWestDrunk. You should implement a method, takeStep(), that returns the x,y values of a random step. EastWest Drunks can only move one step to the east or west.
b. Modify Lab10A_Q3.py to perform the following operations:
i. Create 5 EastWestDrunks and add them to the field.
Note: each walk of each drunk should start from the origin <0,0> iii. For all walks of all drunks you should store the distance between the origin and the final location, and display the average, minimum and maximum distances.

Sample Run:
Average Distance:8.4
Max Distance:22.0 Min Distance:0.0


More products