Reference no: EM132377354
Assignment -
Learning Objectives
Work with realworld datasets that can be represented using linear data structures.
Apply vectorization concepts to an iterative problem.
Explore different programming paradigms to solve problems.
This is an individual homework assignment.
Please complete this homework assignment within the Jupypter notebook environment, making use of Markdown and Code cells to properly format your answers.
Your completed Jupyter notebook is to be submitted via the HW2 dropbox on D2L.
Question 1 - Visualizing trends in an index
"This question asks you to plot the Bitcoin price index (BPI) along with 5-day and 10-day averages. Please execute the code cell below; it will read in a csv file containing the daily closing price from Sep. 1, 2018 to Aug. 31, 2019. Perform the following tasks. You may use any built-in Python functions as well as data strucutres and functions provided by the 'numpy' library.
Observe that the closing prices are at a daily interval. We therefore do not need the date information. Clean up the data and only retain the price information. Store the result in a list or a numpy array in floating point format.
Perform a simple moving average of the price index. The number of days $N$ to average over should be adjustable. If you are using 'numpy', you may find the function.
Plot the raw price index data along with 5-day and 10-day simple moving average. Plot on the same figure in order to help you visually ascertain the effect of the filter.
What is the effect of the moving average filter? In what circumstances would you _not_ want to use a moving average?
Question 2 - Vectorized Race Simulation
1. Eight athletes are competing in a 1500 m race. Using 'numpy' , write a vectorized race simulation according to the following criteria:
The granularity of the simulation is 1 s, i.e. each iteration in your simulation represents 1 second.
During each iteration, each athelete can randomly take 1, 2, 3, or 4 steps. Each step is 1 m long.
When the race is complete, return the winner and the winning time. There should not be any ties. If there is a tie, select a winner at random.
Please pay attention to the following:
There should only be one loop in your simulation: the loop that advances the simulation by a second.
All other operations should be done using vectorized array operations and boolean indexing.
2. Run your simulation 10,000 times. For each run, record the winner and the winning time. Produce a bar chart showing the number of times each athelete won. Also display a bar chart showing the average winning time for each athlete.
Attachment:- Assignment Files.rar