15 08 2009 Python matplotlib PRML Tweet
PRML11章。一様乱数から正規乱数を発生させる。
from math import sin,cos,pi,log,sqrt
from random import random
def box_muller():
z1 = random()
z2 = random()
return sqrt(-2*log(z2)) * sin(2*pi*z1)
if __name__ == "__main__":
from pylab import *
x = [box_muller() for i in range(10000)]
hist(x,20)
savefig("box_muller.png")