# homework | 作业thread | quiz | Python | 代做assignment | 代做lab – Homework Assignment 4

### Homework Assignment 4

This assignment primarily concerns the material in notebooks 8, 12, 13 and the associated labs.

Ensure you do not copy any of the weather data (.csv files) or crime data (the big .jeojson file) into your personal repo. If such files are discovered in your repo you will lose one point on this assignment.

In your labs March 25th–29th we will ask you to move all the code you need from notebooks 8, 12, 13 and the relevant labs into a library that you will import into this notebook, i.e. we ask you to minimize (in this notebook) the amount of recycled code from class and previous labs, to make your work easier to grade.

### P1: Weather data

Load the common weather data for the four cities as we did in Lecture Notebook 12.

a) For each city, and each month, compute the average of: daily max, min and mean temperatures for that month. In more concrete detail: for Edmonton January max temperatures, you would take the average of all the maximum temperatures for every day in January, for all years in which we have data, for the city of Edmonton. You would do the same for every month, and all three temperature readings (daily max, min, mean). Output your answer as four numpy matrices.

b) For every city, and every weather reading (daily max, min, mean), find the weather record where that daily temperature recording differs from the monthly average by the largest amount. i.e. your answer to part (b) will consist of 12 weather records. Please format your answer so that you have your 12=43* answers on one line each. For example, one line would be:

``````Edmonton, Mean Temp (C), avg: AVG, Temp: TMP, Dev: DEV, Date: YYYY-MM-DD
``````

This would be the answer for Edmonton’s Mean temperature readings. YYYY-MM-DD would be the date of the maximum deviation from the average of all temperatures in the month MM. TMP is the temperature reading on that day (in this case, the daily mean temp). AVG is the average of the temperature readings for month MM. DEV is the difference between TMP and AVG, i.e. DEV = TMP-AVG.

In [ ]:

In [ ]:

In [ ]:

### P2: Crime data

Which crimes (use parent_incident_type ) are more common in proximitiy to The Bay Centre, and which are more common far from the Bay Centre? Start your analysis with a histogram using the distance function as in lab 13.b problem 3. I suggest starting your analysis using bin endpoints that are integer multiples of .

Please put any further analysis (by crime) in a text field in your plot. After your histograms, list the parent_incident_types by their from most commonly to least commonly happening in the vicinity of the Bay Centre.

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:

### P3: Crime and Weather data

This problem asks you to compare the Victoria PD Traffic Collision data, on typical days vs. on days when IT snows , also accidents near hills.

(a) For how many days do we have both crime data (from Notebook 13 ) and weather data (see Notebook 8 ) for Victoria? Comment: Regarding Notebook 8, please use the dates from the coml variable. For how many of our crime records do we have weather data?

(b) Compute the average number of COLLISION records (under Traffic — see the ctree variable from Notebook 13) per day (on all days) vs. the average number on days where it snowed.

(c) Repeat (b) but where you restrict yourself to car crashes near major hills in town. Let’s say the major hills are (1) near Trafalgar Park, (2) the corner of Burdett and Blanshard, and (3) one hill of your choice. Find the GPS coordinates of these locations using Google Maps, and restrict yourself to accidents within a 200m radius of those coordinates.

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:

### P4: Quiz.3 revisited

Let’s revisit quiz 3. Write a Python function

collisionPlot(va,vb,ma,mb)

that not only counts all the collisions between the billiards and the wall, but it also plots them. i.e. the output of collisionPlot will be a matplotlib figure similar to

i.e. it will show the paths of the billiards. Thus to solve this problem you will need to compute both the collision times and their locations; not just the velocity sequence.

Include the plots for va=0, vb=-1, ma=1, mb=10, 100. Set your figsize to (8,8) so that the plots are reasonably-large.

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]: