由买买提看人间百态

topics

全部话题 - 话题: iseed2
(共0页)
b********p
发帖数: 875
1
来自主题: Statistics版 - 请教:用C怎么产生uniform的随机数
double randomGen()
{
int kkk,iran;
kkk = iSeed1 / 53668;
iSeed1 = 40014 * (iSeed1 - kkk * 53668) - kkk * 12211;
if(iSeed1 < 0) iSeed1 = iSeed1 + 2147483563;
kkk = iSeed2 / 52774;
iSeed2 = 40692 * (iSeed2 - kkk * 52774) - kkk * 3791;
if(iSeed2 < 0) iSeed2 = iSeed2 + 2147483399;
iran = iSeed1 - iSeed2;
if(iran < 1) iran = iran + 2147483562;
return (iran * 4.656612873e-10);
}
(共0页)