o********g 发帖数: 162 | 1 numerical recipes 上就有呀,我给你COPY 一个在这里, page 289.
#include
float gasdev(idum)
return a normally distributed deviate with zero mean and unit variance,
using ran1(idum) as the source of uniform deviates
int *idum;
{
static int iset=0;
static float gset;
float fac,r,v1,v2;
float ran1();
if (iset == 0) {
do {
v1=2.0*ran1(idum)-1.0;
v2=2.0*ran1(idum)-1.0;
r=v1*v1+v2* |
|