Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random as rnd
- import matplotlib.pyplot as plt
- # import ganas.de.vivir as suicidio
- def browniano(n, μ, σ):
- x = [0]
- y = [0]
- for i in range(n):
- dx = rnd.normalvariate(μ, σ)
- dy = rnd.normalvariate(μ, σ)
- x.append(x[i] + dx)
- y.append(y[i] + dy)
- pass
- return x, y
- σ = 1
- μ = 0
- tiempos = [100, 500, 1000, 5000, 10_000]
- k = 100
- for n, t in enumerate(tiempos):
- promedio = 0
- for j in range(k):
- x, y = browniano(t, μ, σ)
- # plt.subplot(k, len(tiempos), n*k + 1 + j)
- # plt.plot(x, y)
- # plt.title(f"t = {t}, intento = {j + 1}")
- promedio += sum([x1**2 + y1**2 for x1, y1 in zip(x, y)])/t
- print(f"promedio en t = {t}: {promedio/k}")
- # plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement