ボックス=ミューラー法

ボックスミューラー法の養殖された乱数とはww?

10000.times {
  x = rand()
  y = rand()

  z1 = Math.sqrt(-2 * Math.log(x)) * Math.cos(2 * Math::PI * y)
  z2 = Math.sqrt(-2 * Math.log(x)) * Math.sin(2 * Math::PI * y)

  puts "#{z1}\t#{z2}"
}
ruby bm.rb | pbcopy 

googleスプレッドシートに貼り付けてヒストグラムのグラフを作る(重い…)

rand - Google スプレッドシート

f:id:paulownia:20161105120027p:plain

f:id:paulownia:20161105120032p:plain

1万回程度ではあんまり綺麗なグラフにならないすね


おまけ