I have N
agents to place in a grid n x n
following the (truncated Levy) distribution
px = (r + r0)**(-beta)*exp(-r/k)
Each agent has two favorite cells: home
and work
and px
is the probability for each agent to move from home
and work
with a distance r
.
def returnLevy(r, beta):
r0 = 100
k = 1500
px = (r + r0)**(-beta)*exp(-r/k)
return px
I have compute the distance among all the cells in my grid, so
allDistances.head(5):
distances cell_a cell_b
0 1.322959 0 1
1 0.717737 0 2
2 0.454170 0 3
3 0.321495 0 4
4 0.454248 0 5
I would like to know if there is a way to randomly assign to each agent a distance r
from home
and work
following the aforementioned distribution. At the end I would like to have a dataframe:
agentsCells
distance home work
0 1.322959 320 1089
1 0.717737 4 765
2 0.454170 2100 388