Skip to content

Instantly share code, notes, and snippets.

@faroit
Last active August 23, 2021 07:17
Show Gist options
  • Select an option

  • Save faroit/437954cf28d182262fc62e372e5a5e71 to your computer and use it in GitHub Desktop.

Select an option

Save faroit/437954cf28d182262fc62e372e5a5e71 to your computer and use it in GitHub Desktop.
alpha stable noise
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)
@faroit

faroit commented Aug 23, 2021

Copy link
Copy Markdown
Author
gaussian.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment