Skip to content

Instantly share code, notes, and snippets.

@ctralie
ctralie / AutoencoderTest.ipynb
Created January 23, 2022 17:50
Experiments with autoencoders of MNIST Data in pytorch, with a visualization of projection to 2D latent space
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctralie
ctralie / Cantor.ipynb
Created October 21, 2021 14:35
Cantor Function Approximation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctralie
ctralie / colormap.py
Created July 5, 2021 15:46
Colormaps
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from skimage import data
from skimage.color import rgb2gray
from colorspacious import cspace_converter
I = data.astronaut()
I = rgb2gray(I)
cmaps = ['gray', 'magma', 'jet', 'RdGy']
@ctralie
ctralie / VoronoiBrutAnim.py
Created April 16, 2021 02:46
Brute Force Voronoi Animation with Moving Sites in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import KDTree
# Generate some number of sites in
# the square [0, 1] x [0, 1]
np.random.seed(0)
n_sites = 20
sites = np.random.rand(n_sites, 2)
# Create random velocities
@ctralie
ctralie / SquareWave.ipynb
Created February 16, 2021 23:11
DFT of Time Shifting Square Wave
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctralie
ctralie / coolpattern.py
Created March 3, 2020 01:31
Bad Sampling Triangle Wave = Amazing Pattern
import numpy as np
import scipy.io.wavfile as wavfile
import matplotlib.pyplot as plt
duration = 20
fs = 44100
y = np.zeros(fs*duration)
n_harmonics = 5
t = np.arange(fs*duration) # INCORRECT SAMPLING
#t = np.linspace(0, duration, fs*duration) # CORRECT SAMPLING
@ctralie
ctralie / EDMExample.py
Created November 9, 2019 00:16
Fast Euclidean Distance Matrix Computaiton
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def getEDM(X):
"""
Compute an all pairs distance matrix using broadcasting
and matrix multiplications to speed up computations
Parameters
----------
@ctralie
ctralie / makeColorScatterplots.py
Created January 31, 2019 15:59
Plot "time-ordered point clouds" with colors on the rainbow to indicate the time
"""
Programmer: Chris Tralie
Purpose: To show how to plot "time-ordered point clouds"
with colors on the rainbow to indicate the time
(red beginning, magenta end)
"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
@ctralie
ctralie / ConnectionLaplacian.py
Created January 9, 2019 22:31
The connection Laplacian and its use for synchronizing a set of vectors on an NxN grid
"""
Programmer: Chris Tralie ([email protected])
Purpose: To implement the connection Laplacian and show its use
for synchronizing a set of vectors on an NxN grid
"""
import numpy as np
import numpy.linalg as linalg
from scipy import sparse
from scipy.sparse.linalg import lsqr, cg, eigsh
import matplotlib.pyplot as plt