long cls_random::randomBinomial( long N, double probability) { long rnd = 0; for (long i=0;i<N;i++) { double pV = (double)rand()/(double)RAND_MAX; if (pV<probability) { rnd++; } } return rnd; }
期望:E=
方差:V=
wiki:http://zh.wikipedia.org/wiki/%E4%BA%8C%E9%A1%B9%E5%88%86%E5%B8%83