Jim's
Tutorials

Spring 2019
course
site

Apr 16 - Jack

Jim says

You haven't told me where to find your notebooks so I can't look at what you've done.

Jack says

I tested that my method of moving the particles is consistent with the distribution I expect.

The simulation of the experiment (with the autocorrelation and power spectrum stuff) is more or less complete. It generates values for the diameter of the microspheres that, while not entirely accurate, are of the proper order of magnitude, which considering the roughness of the fits due to not being able to simulate many particles is pretty good by my feeling. I did end up cutting out the beginning data because if I used it, I ended up with a diameter around 20-30 cm, which is obviously not correct. The reason I am okay cutting the beginning is because at that point every single particle is in phase, which would never actually happen.

So that's the good news.

The other simulation almost works, by which I mean I have particles bouncing around in ways that make sense (as far as I can see with what data I have). But I get the data for all the times and the position of all the particles at each time. I don't know if it's worth it to try and put this into an animation or if I should just use this data to illustrate that the motion of particle in one dimension is a normal distribution.

Jim on numpy built-in operations rather than loops

numpy docs : operation on an outer product

>>> import numpy as np
>>> x = [1,2,3,4]
>>> np.subtract.outer(x, x)
array([[ 0, -1, -2, -3],
       [ 1,  0, -1, -2],
       [ 2,  1,  0, -1],
       [ 3,  2,  1,  0]])
>>> np.cos(np.subtract.outer(x, x))
array([[ 1.        ,  0.54030231, -0.41614684, -0.9899925 ],
       [ 0.54030231,  1.        ,  0.54030231, -0.41614684],
       [-0.41614684,  0.54030231,  1.        ,  0.54030231],
       [-0.9899925 , -0.41614684,  0.54030231,  1.        ]])
>>> np.sum(np.cos(np.subtract.outer(x, x)))
3.5972414958193784
https://cs.marlboro.college /cours /spring2019 /jims_tutorials /jtuttle /apr15
last modified Mon November 25 2024 10:40 am

attachments [paper clip]

  last modified size
TXT brownianlab_2.html Mon Nov 25 2024 10:40 am 398K
TXT brownianlab_2.ipynb Mon Nov 25 2024 10:40 am 118K
TXT simplebrownian.ipynb Mon Nov 25 2024 10:40 am 26K
TXT simplebrownian_1.html Mon Nov 25 2024 10:40 am 309K