CoCalc Public Files2018-11-23-102108.sagews
Authors: Joel Dahne, Raazesh Sainudiin, Julian Salas
Views : 146
Description: randomWalkersSimulations
Compute Environment: Ubuntu 18.04 (Deprecated)

# Sufficiently Sanitized Mobility Statistics

## Raazesh Sainudiin and Joel Dahne

### directed by Marina Toger and Julián Salas Piñón

This is mainly Raaz's simulations to limit the scope of needed mathematical statistics.

Working collaboratively in the cloud.

def makeRandomWalkTraj(ID=int(0), txy0 = [float(0.0),float(0.0),float(0.0)], steps = int(10),\
xy_move = float(1.0),t_rate = float(1.0)):
itxy=[ID, txy0[0], txy0[1], txy0[2]]
traj=[itxy]
for i in range(steps):
t = itxy[1] + (float(-1.0)/t_rate)*log(float(1.0) - random())
x = itxy[2]+xy_move*random()*float(2.0)+float(-1.0)
y = itxy[3]+xy_move*random()*float(2.0)+float(-1.0)
itxy=[itxy[0], t , x, y]
traj.append(itxy)
return traj

ss=float(10.0) # spatial scale
t = makeRandomWalkTraj(23,\
[random()*float(2.0)+float(-1.0),random()*float(2.0*ss)+float(-1.0*ss),random()*float(2.0*ss)+float(-1.0*ss)],\
int(10),float(1.0),float(1.0))
t

[[23, -0.4659012343959228, -9.575607826557713, 0.17340282805104756], [23, 0.6126479891938093, -9.184760613690155, 0.4885329796159714], [23, 2.6957539280514533, -8.606602981320204, 0.9510692130506782], [23, 6.06959585684219, -8.681472704747904, 1.630766154509188], [23, 7.138921335368573, -7.7102766034082055, 2.4780067265426338], [23, 8.104735646981913, -8.464004907096287, 2.2487166415590747], [23, 8.899272762724815, -8.555205138914507, 1.5181199596044745], [23, 9.322957064997755, -9.38790099954956, 2.1838151104613814], [23, 10.251556511608827, -9.92669144859741, 2.933561360873518], [23, 12.35940116756471, -9.682509445817248, 3.46564251242195], [23, 12.885294796735993, -8.77343276984541, 3.8228980704770095]]
import numpy as np

def makeTraj3DImage(tr,rgb):
a = np.array(tr)
p=points(a[:,1:4],size=5,rgbcolor=rgb,opacity=.5)
p+=line(a[:,1:4],size=5,rgbcolor=rgb,opacity=.5)
return p

numOfIndividuals=50
numSteps=100
ss=float(1.0) # spatial scale
Ts=[]
for i in range(0,numOfIndividuals):
t = makeRandomWalkTraj(i,\
[random()*float(2.0)+float(-1.0),random()*float(2.0*ss)+float(-1.0*ss),random()*float(2.0*ss)+float(-1.0*ss)],\
int(numSteps),float(1.0),float(1.0))
Ts.append(t)

rgbRandomColorMap = [(random(),random(),random()) for i in range(numOfIndividuals)]
p=makeTraj3DImage(Ts[0], rgbRandomColorMap[0])
for i in range(1,numOfIndividuals):
p+=makeTraj3DImage(Ts[i], rgbRandomColorMap[i])
p.show()

3D rendering not yet implemented

### We can take a slice of time at the beginning from the above co-trajectories

$\delta = \sum_{i=1}^n x_i$











help(point3d)

%md
## Joel's Python code

Joel, you could put your python code ina  big block here so we can all play with it more easily.



## Joel's Python code

Joel, you could put your python code ina big block here so we can all play with it more easily.

# Joel's Python code could go in this cell




5 + 5

10