Skip to content

Instantly share code, notes, and snippets.

@ilius
Created May 6, 2024 13:12
Show Gist options
  • Save ilius/980fc64370bc58c500059c10cb35f6ec to your computer and use it in GitHub Desktop.
Save ilius/980fc64370bc58c500059c10cb35f6ec to your computer and use it in GitHub Desktop.
from matplotlib import pyplot
import numpy as np
n = 10000
m = n // 5
scale = 10
def f(x):
y = 0
result = []
for _ in x:
result.append(abs(y))
y += np.random.normal(scale=scale)
return np.array(result)
def runningMean(x, N):
return np.convolve(x, np.ones((N,)) / N)[(N - 1) :]
x = np.linspace(0, n, n)
pyplot.plot(x, runningMean(f(x), m))
pyplot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment