Csound Csound-dev Csound-tekno Search About

Techquiz: ftp PRNG in rnd/birnd?

Date1999-09-19 11:33
Fromrasmus ekman
SubjectTechquiz: ftp PRNG in rnd/birnd?
Yo, maths buffs,

Below is the code used internally by the rnd / birnd pseudo-random 
generators in Aops.c. It uses some floating point algorithm. 
For curiosity and documentation purposes I'd like to know its
performance: How many bits does it output - ie, how many 
different values? (2^23?)
What length is the cycle? 
Where does it come from? etc.

Anybody?

	re


static double rndfrac = .5, rndmlt = 105.947;

void rnd1(EVAL *p)              /* returns unipolar rand(x) */
{
	double intpart;
	rndfrac = modf(rndfrac * rndmlt, &intpart);
	*p->result = p->ampscale * (FLOAT)rndfrac;