<jupyter_start><jupyter_text>Your name here.  Your Woskshop section here.  Homework 3: Arrays,  File I/O and Plotting **Submit this notebook to bCourses to receive a grade for this Workshop.**Please complete homework activities in code cells in this iPython notebook. Be sure to comment your code well so that anyone who reads it can follow it and use it. Enter your name in the cell at the top of the notebook. When you are ready to submit it, you should download it as a python notebook (click "File", "Download as", "Notebook (.ipynb)") and upload it on bCourses under the Assignments tab. Please also save the notebook as PDF and upload to bCourses.   Problem 1: Sunspots[Adapted from Newman, Exercise 3.1] At this link (and also in your current directory on datahub) you will find a file called `sunspots.txt`, which contains the observed number of sunspots on the Sun for each month since January 1749. The file contains two columns of numbers, the first being the month and the second being the sunspot number.a. Write a program that reads in the data and makes a graph of sunspots as a function of time. Adjust the $x$ axis so that the data fills the whole horizontal width of the graph. b. Modify your code to display two subplots in a single figure: The plot from Part 1 with all the data, and a second subplot with the first 1000 data points on the graph. c. Write a function `running_average(y, r)` that takes an array or list $y$ and calculates the running average of the data, defined by $$ Y_k = \frac{1}{2r+1} \sum_{m=-r}^r y_{k+m},$$where $y_k$ are the sunspot numbers in our case. Use this function and modify your second subplot (the one with the first 1000 data points) to plot both the original data and the running average on the same graph, again over the range covered by the first 1000 data points. Use $r=5$, but make sure your program allows the user to easily change $r$. The next two parts may require you to google for how to do things. Make a strong effort to do these parts on your own without asking for help. If you do ask for help from a GSI or friend, first ask them to point you to the resource they used, and do your best to learn the necessary techniques from that resource yourself. Finding and learning from online documentation and forums is a very important skill. (Hint: Stack Exchange/Stack Overflow is often a great resource.)d. Add legends to each of your subplots, but make them partially transparent, so that you can still see any data that they might overlap. *Note: In your program, you should only have to change $r$ for the running average in one place to adjust both the graph and the legend.* e. Since the $x$ and $y$ axes in both subplots have the same units, add shared $x$ and $y$ labels to your plot that are centered on the horizontal and vertical dimensions of your figure, respectively. Also add a single title to your figure.When your are finished, your plot should look something close to this:<jupyter_code># Don't rerun this snippet of code.
# If you accidentally do, uncomment the lines below and rerun

#from IPython.display import Image
#Image(filename="img/p1_output.png")<jupyter_output><empty_output><jupyter_text>Hints* The running average is not defined for the first and last few points that you're taking a running average over. (Why is that?) Notice, for instance, that the black curve in the plot above doesn't extend quite as far on either side as the red curve. For making your plot, it might be helpful if your `running_average` function returns an array of the $x$-values $x_k$ (or their corresponding indices $k$) along with an array of the $y$-values $Y_k$ that you compute for the running average.* You can use the Latex code `$\pm$` for the $\pm$ symbol in the legend. You can also just write `+/-` if you prefer.  Problem 2: Variety PlotIn this problem, you will reproduce the following as a single figure with four subplots, as best you can:<jupyter_code># Don't rerun this snippet of code.
# If you accidentally do, uncomment the lines below and rerun

#from IPython.display import Image
#Image(filename="img/p2_output.png")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.05527395607048033, 'fraction_numerical': 0.006758387641805455, 'mean_word_length': 4.459815546772068, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '10236', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1046, 'n_words': 689, 'path': 'Week06/Homework03.ipynb', 'repo_name': 'ds-connectors/Physics-88-Sp21', 'size': '4143'}