Skip to content

Instantly share code, notes, and snippets.

View ManojKumarTiwari's full-sized avatar
🎯
Focusing

Manoj Kumar Tiwari ManojKumarTiwari

🎯
Focusing
  • Capgemini
  • Bangalore
View GitHub Profile
@RobertTLange
RobertTLange / jax_ou_process.py
Created March 5, 2021 19:32
Ornstein-Uhlenbeck Process in JAX
import jax
import jax.numpy as jnp
def ou_process(key, steps, dt, mu, tau, sigma):
""" Generate an Ornstein-Uhlenbeck process sample. """
ou_init = jnp.zeros((steps + 1, ))
noise = jax.random.normal(key, (steps,))
def ou_step(t, val):
dx = (-(val[t-1]-mu)/tau * dt
+ sigma*jnp.sqrt(2/tau)*
@sloria
sloria / recorder.py
Last active April 12, 2024 11:43
WAV recording functionality using pyaudio
# -*- coding: utf-8 -*-
'''recorder.py
Provides WAV recording functionality via two approaches:
Blocking mode (record for a set duration):
>>> rec = Recorder(channels=2)
>>> with rec.open('blocking.wav', 'wb') as recfile:
... recfile.record(duration=5.0)
Non-blocking mode (start and stop recording):