0
$\begingroup$

I have a single particle trajectory and would like to calculate the mean squared displacement. The particle is moving from blue over yellow, green to red data points.

The {x,y} data are available here: http://pastebin.com/qxFv4jg1

enter image description here

I would like to calculate the mean squared displacement and plot it against the lag time as shown in the following plot:

enter image description here

(image taken from https://de.wikipedia.org/wiki/Mittlere_quadratische_Verschiebung#/media/File:Randomwalk_msd.svg)

From that finally I could calculate the diffusion coefficient D.

The mean-square displacement in 2 dimensions is: <x^2> = 4*D*t

whereby:

x is the mean distance from the starting point that the particle is diffused in time t

D is the diffusion coefficient (usual units are cm^2/sec).

How can that be done effectivelly with mathematica?

$\endgroup$
2
  • 2
    $\begingroup$ Please include the code you have developed for this purpose and describe the difficulties you are having. $\endgroup$
    – bbgodfrey
    Nov 27 '15 at 13:58
  • $\begingroup$ To come up with an answer, most of us (certainly me), would need to experiment with your code. But you give us code with undefined symbols that won't evaluate. So you are unlikely to get an answer unless you edit your question to include *all the code needed to make your example code self-contained. $\endgroup$
    – m_goldberg
    Nov 27 '15 at 14:05
1
$\begingroup$

If I guess right, you have a sort of Brownian motion, and the mean squared displacement you need should be counted off from the initial point, right? If so, here is the initial part of your list of data:

lst = {{0.0991034, 0.0603103}, {0.101192, 0.0624692}, {0.102, 
0.0638}, {0.103869, 0.0658385}, {0.105071, 0.0684048}, {0.107146, 
0.0718385}, {0.109548, 0.0743571}, {0.110438, 
0.0779531}, {0.112246, 0.0810763}, {0.112858, 
0.0847836}, {0.113455, 0.0875909}, {0.11579, 
0.0900968}, {0.117119, 0.0944048}, {0.119262, 
0.0980714}, {0.118833, 0.102262}, {0.120387, 0.105242}, {0.1206, 
0.10915}, {0.121085, 0.112638}, {0.120713, 0.115746}, {0.121943, 
0.119139}, {0.1217, 0.12275}, {0.12269, 0.125431}, {0.124597, 
0.127887}, {0.125582, 0.130549}, {0.126268, 0.132321}, {0.126414, 
0.134017}, {0.126776, 0.135569}, {0.12691, 0.137041}, {0.126429, 
0.138}, {0.125533, 0.139402}, {0.124597, 0.140419}, {0.122484, 
0.140344}, {0.120229, 0.1395}, {0.1184, 0.1392}, {0.115839, 
0.138048}, {0.113468, 0.136113}, {0.112452, 0.132871}};

and you might try the following code giving the standard deviation versus the number of the pair in your data list:

d = Table[{i, 


StandardDeviation[
     Map[Subtract[#, lst[[1]]] &, Take[lst, i]]] /. {x_, y_} -> 
     x^2 + y^2}, {i, 2, Length[lst]}]

    (*  {{2, 4.51155*10^-6}, {3, 5.33588*10^-6}, {4, 9.28787*10^-6}, {5, 
  0.0000150766}, {6, 0.0000258761}, {7, 0.0000389204}, {8, 
  0.0000543391}, {9, 0.0000723614}, {10, 0.0000927279}, {11, 
  0.000112821}, {12, 0.000134572}, {13, 0.000162036}, {14, 
  0.000193961}, {15, 0.000228093}, {16, 0.000263232}, {17, 
  0.000300936}, {18, 0.00034018}, {19, 0.000378949}, {20, 
  0.000420114}, {21, 0.000463006}, {22, 0.000505667}, {23, 
  0.000548461}, {24, 0.000591407}, {25, 0.000631614}, {26, 
  0.000668875}, {27, 0.00070348}, {28, 0.000735474}, {29, 
  0.000763479}, {30, 0.000789021}, {31, 0.000811599}, {32, 
  0.00082874}, {33, 0.000839905}, {34, 0.000847474}, {35, 
  0.000850705}, {36, 0.000849415}, {37, 0.000842648}}  *)

looking as follows:

ListPlot[d]

enter image description here

Have fun!

$\endgroup$
2
  • $\begingroup$ It would be great if you could help me once again: Is the MSD not obtained by Mean instead of StandardDeviation. If so, I do not understand why the StandardDeviation is so large compared to the Mean? $\endgroup$
    – mrz
    Apr 1 '16 at 22:04
  • $\begingroup$ @mrz It depends on what do you need to calculate. I cannod advice you, what to calculate, you should know it yourself: it follows from the problem that you are solving. I only have given you an idea of how this kind of things could be done. In particular one can express the displacement using the Mean function. Take care only that to first subtract the initial position from all coordinates. $\endgroup$ Apr 3 '16 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.