Last active
August 23, 2021 07:17
-
-
Save faroit/437954cf28d182262fc62e372e5a5e71 to your computer and use it in GitHub Desktop.
alpha stable noise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.animation as animation | |
import matplotlib.pyplot as plt | |
from collections import deque | |
import numpy as np | |
from matplotlib import pyplot as plt | |
from matplotlib.animation import FuncAnimation | |
import scipy.stats | |
plt.style.use('seaborn-pastel') | |
Writer = animation.writers['ffmpeg'] | |
writer = Writer(fps=30, metadata=dict(artist='Me'), bitrate=1800) | |
def animate(i): | |
global x, alpha | |
x += 1 | |
if x < 400: | |
alpha = 2.0 | |
else: | |
alpha = 800 / x | |
y = scipy.stats.levy_stable.rvs(alpha, beta=0, loc=0, scale=1, size=1, random_state=None)[0] | |
ttl.set_text(str(alpha)) | |
data.append((x, y)) | |
ax.relim() | |
ax.autoscale_view(True, True, True) | |
line.set_data(*zip(*data)) | |
fig, ax = plt.subplots() | |
x = 0 | |
y = np.random.randn() | |
ttl = ax.text(.5, 1.05, '', transform=ax.transAxes, va='center') | |
data = deque([(x, y)], maxlen=200) | |
line, = plt.plot(*zip(*data), c='black') | |
ani = animation.FuncAnimation(fig, animate, frames=2000) | |
ani.save('gaussian.mp4', writer=writer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gaussian.mp4