This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
#################################################### | |
# # | |
# Markov Mixer # | |
# EE 126 # | |
# # | |
#################################################### | |
# +envelope # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_matrix(mat,rvalues=None,cvalues=None): | |
# print a 2d numpy array as a table, using the optional rvalues | |
# and cvalues as row and column labels | |
if rvalues==None: | |
rvalues=np.arange(mat.shape[0]) | |
if cvalues==None: | |
cvalues=np.arange(mat.shape[1]) | |
print ("{:5}"+"{:^6} "*mat.shape[1]).format('',*cvalues) | |
print ("{:5}"+"{:^6} "*mat.shape[1]).format('',*["-----" for i in cvalues]) | |
for i,r in enumerate(rvalues): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on init | |
declare $last_groupid := -1 | |
declare $new_groupid | |
declare $N | |
end on | |
on note | |
$N := $NUM_GROUPS | |
disallow_group($ALL_GROUPS) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Example kernels | |
def uniform_kernel(x): | |
norm_coeff = .5 | |
return .5*np.bitwise_and(-1<x,1>x) | |
def normal_kernel(x): | |
norm_coeff = (2*np.pi)**-.5 | |
return .5*np.exp(-.5*x**2) |