Hints for Lab 6: Random walk and Brownian motion#

For the class on Wednesday, January 31st

See also

Go back to Lab 6

A. Scaling and convergence of the diffusively rescaled random walk#

Hints for Part A
  • To calculate the quantile function (recall Lab 1A), you can use the following calc_quantile function.

    import numpy as np
    
    def calc_quantile(data):
        n = np.asanyarray(data).size
        q = (np.arange(n) + 0.5) / n
        return q, np.quantile(data, q)
    
  • You can compare the calculated quantile function with any known quantile function by making a q-q plot. Below is an example of comparing with the Standard normal distribution.

    import scipy.stats
    import matplotlib.pyplot as plt
    
    q, qf = calc_quantile(data)
    plt.plot(qf, scipy.stats.norm.ppf(q))
    plt.xlabel("data")
    plt.ylabel("normal")
    

B. Universality of simple random walks#

Hints for Part B
  • Use np.random.default_rng().uniform to sample \(\mathcal{U}(-1, 1)\)

    s = np.random.default_rng().uniform(-1, 1, size=n_steps_total)
    
  • The new distribution of \(W_{N=100}(t=1)\) may look like a normal distribution but with a different variance!