#ifndef CA_UWATERLOO_ALUMNI_DWHARDER_CENTRAL_LIMIT_THEOREM #define CA_UWATERLOO_ALUMNI_DWHARDER_CENTRAL_LIMIT_THEOREM // Author: Douglas Wilhelm Harder // Copyright (c) 2012 by Douglas Wilhelm Harder. All rights reserved. // On successive calls to randn_clt(), this function returns // a random standard normal value (a mean of zero and standard deviation of one). // // It generates twelve uniformly distributed values on the interval [0, 1], adds them, and subtracts // six giving a reasonably close approximation to a standard normal. #include #include double randn_clt() { double u = 0.0; int i; for ( i = 0; i < 12; ++i ) { u += drand48(); } return u - 6.0; } #endif