Skip to content

Instantly share code, notes, and snippets.

View rsokl's full-sized avatar
🕳️

Ryan Soklaski rsokl

🕳️
View GitHub Profile
@rsokl
rsokl / Notebook with metadata and long cells.md
Last active March 25, 2019 17:34
Proposed changes to jupytext-markdown
jupyter
kernelspec
display_name language name
Python 3
python
python3

Part one - various cells

@rsokl
rsokl / prob_links.md
Last active December 9, 2019 21:01
Probabilistic Programming Resources
@rsokl
rsokl / ecdf.py
Last active April 6, 2022 16:16
ecdf : empirical cumulative distribution function
import numpy as np
def ecdf(data):
"""Returns (x) the sorted data and (y) the empirical cumulative-proportion
of each datum.
Parameters
----------
data : numpy.ndarray, size-N
@rsokl
rsokl / get_fourier_components.py
Last active May 30, 2020 04:37
Returns individual terms of inverse DFT of a function
def get_fourier_components(
func, num_samples, domain_length, sort_by_descending_magnitude=False
):
"""
Returns the N // 2 + 1 amplitude-phase terms of the inverse D series
of func(t), where funct t is evaluated on [0, T) in N evenly-spaced points.
I.e each component
A[k] cos(2*pi * f[k] * t + phi[k])
@rsokl
rsokl / hydra_zen_plot_landscape.py
Created April 16, 2021 02:08
A code snippet for plotting a job from hydra-zen
def plot_jobs(*jobs, fn):
import numpy as np
import matplotlib.pyplot as plt
(jobs,) = jobs
x, y = np.arange(-2, 2, 0.1), np.arange(-2, 2, 0.1)
X, Y = np.meshgrid(x, y)
V = parabaloid(X, Y)
fig, ax = plt.subplots()
@rsokl
rsokl / autograd_mygrad_compare.md
Last active April 21, 2021 03:44
Some notes on MyGrad and Autograd

A Crude Prototype of Using MyGrad w/ xarray

import xarray as xr
import mygrad as mg

x = xr.DataArray(mg.arange(3.))
y = xr.DataArray(mg.arange(9.).reshape(3, 3))
z = x * y
def local_peaks(
log_spectrogram: np.ndarray, amp_min: float, p_nn: int
) -> List[Tuple[int, int]]:
"""
Defines a local neighborhood and finds the local peaks
in the spectrogram, which must be larger than the
specified `amp_min`.
Parameters
----------