date: 2014-02-27 18:00 tags: [] categories: []
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
Generative programming in Go. | |
こちらのエントリ http://blog.monochromegane.com/blog/2015/03/04/argen/ で紹介した `argen` をつくって得られた go generate まわりの知見を発表します。 | |
# What | |
argenの簡単な紹介を通してGo言語でのGenerative programmingとは何かを説明します。 | |
# Why |
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 os | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def plot(f, points): | |
n = int(f.split('_')[1].split('.')[0]) | |
size = 100 | |
scores = np.loadtxt("tmp/{}".format(f), delimiter=",").reshape(size, size) | |
xs = np.linspace(-2.5, 2.5, size, endpoint=False) |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"math/rand" | |
) | |
var ( | |
Seed int64 |
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 argparse | |
import math | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def plot_exp_pdf(ax, lambda_): | |
def exp(lam, x): | |
if (x >= 0): | |
return lam * np.exp(-lam * x) | |
return 0 |
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 argparse | |
import math | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib import animation | |
def pdf_gamma(x, k, lambda_): | |
return (math.pow(lambda_, k)/math.gamma(k)) * math.pow(x, k-1) * math.exp(-lambda_*x) | |
def plot_gamma(ax, alpha, gamma, title): |