Homework 3, Feb 2025¶
Plot the number of days with positive temperature (in Celsius) in Stockholm from 1756 till this year. Download the data file
stockholm_daily_mean_temperature.csv
from https://bolin.su.se/data/stockholm-historical-daily-temperature-2?n=stockholm-historical-temps-daily-2 . Note that some dates in which data is missing have very negative temperature.Write a Python program that simulates and plots the distance reached by a 2D random walker after $N$ steps, where $N$ ranges from 0 to 1000. The walker moves in discrete steps chosen from the set of
moves=[[0,1],[0,-1],[1,0],[-1, 0]]
, corresponding to up, down, right, and left. Theoretically, the expected distance after $N$ steps is $\frac{\sqrt{\pi}}{2}\sqrt{N}$. However, a single random walker will rarely match this distance exactly. To see how the average behavior approaches this theoretical curve, simulate $N_{walk}=1000$ random walkers, each taking up to 1000 steps. Compute and plot the average distance at each step $N$ over all walkers. Show that the averaged distance curve approximates $\frac{\sqrt{\pi}}{2}\sqrt{N}$ when $N_{walk}$ is large.