# Box and Muller; Normal distributed random number # SysSW, SysZ1, SysZ2 はグローバル変数(他の関数で使ってはいけない) function n_rand( u1, u2) { SysSW = 1-SysSW if (SysSW == 1) { u1 = sqrt(-2.0*log(rand())) u2 = 6.283185307179586*rand() SysZ1 = u1*cos(u2) SysZ2 = u1*sin(u2) return SysZ1 } else { return SysZ2 } }