Calculate the Euclidian distance between coordinates at differents step in time
| Example : |
|---|
>>> from complex_systems.mobility.levy_flight import *
>>> X = [0,0,0]
>>> Y = [1,2,3]
>>> distance(X,Y)
[1.0,1.0]
| Parameters : |
|---|
X coordinates
Y coordinates
| Returns : |
|---|
Euclidian distance
This code is based on the following paper:
| [Rhee08] | Injong Rhee, Minsu Shin, Seongik Hong, Kyunghan Lee and Song Chong, “On the Levy-walk Nature of Human Mobility”, INFOCOM, Arizona, USA, 2008 |
Note
| Levy Flight or Levy Walk model: | |
|---|---|
The Levy Walk generalize the concept of random walker with jump length distribution \(p(\Delta x)\) and and waitting time distribution \(p(\Delta t)\) for waitting ting time \(\Delta t_i\) and jump length \(\Delta x_i\) at evry steps \(i = 1, 2, ..., n\) of the walk.
\[\begin{split}p(\Delta x) \sim \frac{1}{(\Delta x)^{1+\alpha} },\ \ \ p(\Delta t) \sim \frac{1}{(\Delta t)^{1+\beta} }, \ \alpha , \beta > 0\end{split}\]
|
|
| Example : |
|---|
>>> from complex_systems.mobility.levy_walk import *
>>> levy_walk(alpha=0.66, beta=0.99, sample_length=1, size_max=83000, velocity=1.0, f_min=8, f_max=83000, s_min=0.8, s_max=430, duration=500, b_c=2)
| Parameters : |
|---|
Levy exponent for flight length distribution, 0 < alpha <= 2
Levy exponent for pause time distribution, 0 < beta <= 2
Sample time in mins
size of simulation area
speed in m/s
min flight length
max flight length
min pause time (second)
max pause time (second)
simulation duration (minutes)
| Returns : |
|---|
list of X location
list of Y location
time in seconds
list of jump length
list of pause time length
list of X location at sampled intervals
list of Y location at sampled intervals
list of sampled intervals
Stable Random Number Generator (McCulloch 12/18/96) based on the paper [Cha71]
Returns m x n matrix of iid stable random numbers with characteristic exponent alpha in [.1,2], skewness parameter beta in [-1,1], scale c > 0, and location parameter delta. Based on the method of [Cha71] .
| History of this Code: | |
|---|---|
| Parameters : |
|---|
Characteristic exponent in [.1,2]
Skewness in [-1,1]
Scale c > 0
Location parameter
Dimension of the matrix resultat
| Returns : |
|---|
Note
The CMS method is applied in such a way that x will have the log characteristic function
where
With this parameterization, the stable cdf, see [Mcc96] for details.
When \(\alpha = 2\):, the distribution is Gaussian with mean delta and variance \(2 c^2\), and beta has no effect.
When \(\alpha > 1\), the mean is delta for all \(\beta\).
When \(\alpha <= 1\), the mean is undefined.
When \(\beta = 0\), the distribution is symmetrical and delta is the median for all \(\alpha\).
When \(\alpha = 1\) and \(\beta = 0\), the distribution is Cauchy (arctangent) with median \(\delta\).
When the submitted \(\alpha\) is > 2 or < .1, or \(\beta\) is outside [-1,1], an error message is generated and x is returned as a matrix of NaNs.
\(\alpha < 0.1\) is not allowed here because of the non-negligible probability of overflows.
If you’re only interested in the symmetric cases, you may just set \(\beta = 0\) and skip the following considerations:
When \(\beta > 0, (< 0)\), the distribution is skewed to the right (left).
When \(\alpha < 1, \delta\), as defined above, is the unique fractile that is invariant under averaging of iid contributions. I call such a fractile a “focus of stability.” This, like the mean, is a natural location parameter.
When \(\alpha = 1\), either every fractile is a focus of stability, as in the \(\beta = 0\) Cauchy case, or else there is no focus of stability at all, as is the case for \(\beta ~= 0\). In the latter cases, which I call “afocal,” delta is just an arbitrary fractile that has a simple relation to the c.f.
When \(\alpha > 1 and \beta > 0\), med(x) must lie very far below the mean as alpha approaches 1 from above. Furthermore, asalpha approaches 1 from below, med(x) must lie very far above the focus of stability when \(\beta > 0\). If \(\beta ~= 0\), there is therefore a discontinuity in the distribution as a function of alpha as alpha passes 1, when delta is held constant. CMS, following an insight of Vladimir Zolotarev, remove this discontinuity by subtracting:
in their program RSTAB, a.k.a. RNSTA in IMSL (formerly GGSTA). The result is a random number whose distribution is a continuous function of alpha, but whose location parameter (which I call zeta) is a shifted version of delta that has no known interpretation other than computational convenience.
The present program restores the more meaningful \(\delta\) parameterization by using the CMS (4.1), but with \(\beta \cdot c \cdot tan(\pi \alpha/2)\) added back in (ie with their initial \(tan(\alpha \phi_0)\) deleted). RNSTA therefore gives different results than the present program when \(\beta ~= 0\). However, the present beta is equivalent to the CMS beta’ (BPRIME).
Rather than using the CMS D2 and exp2 functions to compensate for the ill- condition of the CMS (4.1) when \(\alpha\) is very near 1, the present program merely fudges these cases by computing \(x\) from their (2.4) and adjusting for \(\beta \cdot c \cdot tan(\pi \alpha/2)\) when alpha is within 1.e-8 of 1. This should make no difference for simulation results with samples of size less than approximately 10^8, and then only when the desired alpha is within 1.e-8 of 1, but not equal to 1.
The frequently used Gaussian and symmetric cases are coded separately so as to speed up execution.
| [Mcc96] | J.H. McCulloch, “On the parametrization of the afocal stable distributions,” Bull. London Math. Soc. 28 (1996): 651-55, |
| [Zov86] | V.M. Zolotarev, “One Dimensional Stable Laws,” Amer. Math. Soc., 1986. |
| [Sam94] |
|
| [Jan94] |
|
| [Mcc97] | J.H. McCulloch, “Financial Applications of Stable Distributons,” Handbook of Statistics, Vol. 14, 1997. |