RACIPELIB.c
// Generate random value following guassian distribtuion N(m, stadvalue)
Generate random value following guassian distribtuion N(m, stadvalue)
Generate random value following guassian distribtuion N ( m stadvalue )
double randg(double m, double stdvalue)
{
  double u1 = 0.0, u2 = 0.0, rsq = 0.0, fac = 0.0;
  static double z1 = 0.0, z2 = 0.0;   
  static int call = 0;
  if (call == 1){
    call = !call;
    return z2*stdvalue + m;
  }
  do {
    u1 = 2.0*randu(0, 1) - 1;
    u2 = 2.0*randu(0, 1) - 1;
    rsq = u1*u1 + u2*u2;
  } while (rsq >= 1.0 || rsq == 0.0);
  fac = sqrt(-2.0*log(rsq)/rsq);
  z1 = u1*fac;
  z2 = u2*fac;
  call = !call; 
  return z1*stdvalue + m;  
}
double randg ( double m , double stdvalue ) { double u1 = 0.0 , u2 = 0.0 , rsq = 0.0 , fac = 0.0 ; static double z1 = 0.0 , z2 = 0.0 ; static int call = 0 ; if ( call == 1 ) { call = ! call ; return z2 * stdvalue + m ; } do { u1 = 2.0 * randu ( 0 , 1 ) - 1 ; u2 = 2.0 * randu ( 0 , 1 ) - 1 ; rsq = u1 * u1 + u2 * u2 ; } while ( rsq >= 1.0 || rsq == 0.0 ) ; fac = sqrt ( -2.0 * log ( rsq ) / rsq ) ; z1 = u1 * fac ; z2 = u2 * fac ; call = ! call ; return z1 * stdvalue + m ; }
Generate random value following guassian distribtuion N(m, stadvalue)
Generate random value following guassian distribtuion N ( m stadvalue )