Skip to content

Instantly share code, notes, and snippets.

@ctralie
ctralie / GreedyFurthestPoint.py
Last active December 12, 2023 22:20
Greedy Furthest Point Sampling
"""
Programmer: Chris Tralie
Purpose: To demonstrate a greedy furthest point sampling, which is a general technique
for getting good points that are "spread out" and cover the dataset well
"""
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics.pairwise import pairwise_distances
def getGreedyPerm(D):
@ctralie
ctralie / DTW.py
Last active April 21, 2023 23:29
Dynamic Time Warping Animation
"""
Programmer: Chris Tralie
Purpose: To illustrate the dynamic time warping algorithm
to synchronize two 2D trajectories
"""
import numpy as np
import matplotlib.pyplot as plt
def getCSM(X, Y):
"""
@ctralie
ctralie / Airplane.txt
Created September 1, 2018 13:38
CurvatureScaleSpace
64 235 65 234 66 234 67 234 68 233 69 233 70 233 71 232 72 232 73 232 74 232 75 232 76 231 77 231 78 231 79 231 80 231 81 230 82 230 83 230 84 230 85 230 86 230 87 230 88 230 89 230 90 230 91 229 92 229 93 229 94 229 95 229 96 229 97 229 98 229 99 229 100 229 101 228 102 227 101 226 100 226 99 226 99 225 99 224 100 224 101 224 101 225 102 226 103 226 104 226 105 227 106 227 107 227 108 226 109 226 110 226 111 226 112 226 113 225 114 225 115 225 116 225 117 225 118 224 119 224 120 224 121 224 122 224 123 224 124 223 125 223 126 223 127 222 128 222 129 222 130 222 131 222 132 222 133 221 134 221 135 221 136 221 137 221 138 221 139 221 140 221 141 221 142 221 143 221 144 221 145 221 146 221 147 221 148 221 149 221 150 221 151 221 152 221 153 221 154 221 155 221 156 221 157 221 158 221 159 221 160 221 161 221 162 221 163 221 164 221 165 221 166 221 167 221 168 221 169 221 170 221 171 221 172 221 173 221 174 221 175 221 176 221 177 221 178 221 179 221 180 221 181 221 182 221 183 221 184 221 185 221 186 221 187 221
@ctralie
ctralie / testOt.py
Created November 14, 2018 01:43
2D Histogram Wasserstein Distance via POT Library
"""
Programmer: Chris Tralie
Purpose: To use the POT library (https://github.com/rflamary/POT)
to compute the Entropic regularized Wasserstein distance
between points on a 2D grid
"""
import numpy as np
import matplotlib.pyplot as plt
import ot
@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
@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 / 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 / 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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.