def __get_waiting_time(self):
"""
Extract a waiting time from a power law with exponential cut-off distribution.
The parameters of the distribution are taken from the paper:
C. Song et al., Modelling the scaling properties of human mobility, Nature Physics 6, 818-823 (2010).
---
To simulate a power law with exponential cut-off x^(-alpha) * exp(-lambda * x), we can generate an exponentially
distributed random number U and then accept or reject it with probability p or 1-p respectively (i.e. accept if U < p
or reject if U > p, where U is a uniform [0, 1] random variable), where p = (x/x_min)^(-alpha) and x_min=1.
http://www.santafe.edu/aaronc/powerlaws/
---
:return: float
a waiting time chosen from the waiting time distribution
"""
x = expon.rvs(1.0/self.tau)
while pow(x, -(1 + self.beta)) < uniform(0.0, 1.0):
x = expon.rvs(1.0/self.tau)
return x
评论列表
文章目录