高斯分布也称为正态分布(normal distrib tion) 常用的成熟的生成高斯分布随机数序列的方法由marsaglia和bray在1964年提出,c版本如下 #incl de #incl de #incl de do ble ga ssrand{ static do ble v1, v2, s; static int phase = 0; do ble x; if (0 == phase) { do { do ble 1 = (do ble)randrand_max; do ble 2 = (do ble)randrand_max; v1 = 2 * 1 - 1; v2 = 2 * 2 - 1; s = v1 * v1 + v2 * v2; } while ( 1 = s || 0 == s); x = v1 * sqrt(-2 * log(s)  s); } else { x = v2 * sqrt(-2 * log(s)  s); } phase = 1 - phase; ret rn x; }int main{ srand(time(null)); for (size_t i = 0; i span 10; i) { std::co t  ga ssrand  " "; } sd::co t  std::endl;} 这样生成的高斯分布随机数序列的期望为0.0,方差为1.0.