# -*- coding: utf-8 -*-
"""
Created on Fri Oct 26 15:50:29 2018

@author: Benjamin
"""

""" Tracer une trajectoire de particule en mouvement brownien 1D."""

import matplotlib.pyplot as plt
import random

# Position initiale au centre
x, y = 0.0, 0.0
# Listes des positions, avec la position initiale
x_list = [x]
y_list = [y]
# Nombre de collisions
coll = 1000
# Déplacement maximum par pas de temps
ell = 0.5

# Calculer une trajectoire
for i in range(coll):
   # Tirer au sort le déplacement uniforme entre -ell et +ell
   dx, dy = random.uniform(-ell,ell), random.uniform(-ell,ell)
   # En déduire la nouvelle position
   x, y = x + dx, y + dy
   # L'ajouter aux listes
   x_list.append(x)
   y_list.append(y)
    
# Tracer la trajectoire
plt.figure()
plt.grid()
plt.scatter(x_list, y_list,c= range(len(x_list)), marker = '.', s=200)
plt.axis('equal')
plt.show()