Skip to content

Instantly share code, notes, and snippets.

View hfm's full-sized avatar

Okumura Takahiro hfm

View GitHub Profile
@hfm
hfm / gist:a52fb0fab43d416941cefaac0af78d7d
Created June 4, 2016 15:45 — forked from munhitsu/gist:3938829
augeas/augtool + puppet update /etc/hosts file
$puppetmaster_ip = '8.8.8.8'
augeas { "puppetmaster_in_hosts_append":
context => "/files/etc/hosts",
changes => [
"set 01/ipaddr '${puppetmaster_ip}'",
"set 01/canonical puppet",
],
onlyif => "match *[ipaddr = '${puppetmaster_ip}'] size == 0"
} -> augeas { "puppetmaster_in_hosts_update":
@hfm
hfm / gmm.py
Created November 5, 2012 16:42 — forked from phelrine/gmm.py
混合ガウス分布のパラメータ推定
import numpy as np
import numpy.random as rand
import matplotlib.pyplot as plt
def dnorm(x, m, s):
return np.exp(-((x - m) ** 2) / (2 * s)) / np.sqrt(2 * np.pi * s)
def EM(data, init, iter):
@hfm
hfm / em.py
Created November 5, 2012 15:34 — forked from showyou/em.py
EM Algorithm
import numpy as np
import numpy.random as rand
import matplotlib.pyplot as plt
def mixture_gaussian(i):
pi_0 = 0.3
if rand.random() < pi_0:
return rand.normal(-5, 1)
else:
@hfm
hfm / hellinger.py
Created November 2, 2012 12:07 — forked from larsmans/hellinger.py
Hellinger distance for discrete probability distributions in Python
"""
Three ways of computing the Hellinger distance between two discrete
probability distributions using NumPy and SciPy.
"""
import numpy as np
from scipy.linalg import norm
from scipy.spatial.distance import euclidean
@hfm
hfm / uninstall_homebrew.sh
Created July 14, 2012 12:22 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e