Hello, newbie here in need of some help: I'm trying to generate white noise. I found a paper online called "Xorshift RNG's" by George Marsaglia, and found it attractive because of its simplicity, and its also supposed to generate very good random numbers that have long periods, pass the diehard randomness tests, etc. The problem is, I have a 24-bit codec so I have to shave off 8 bits when I output the stream as noise. When I look at the signal analysis of the output, not only are there unacceptable +/-5dB or so variations, but the energy RISES at 3dB/octave across the spectrum. (???) My question is: assuming I have a 32-bit random number generator that is working properly, should I still see white noise if I only output 24 bits of that noise? Or will I get the strange behavior described above? Any help is much appreciated!

# white noise generation

Started by ●July 3, 2008

Reply by ●July 3, 20082008-07-03

esfield wrote:> The problem is, I have a 24-bit codec so I have to shave off 8 bits when IIs this a sigma-delta (or delta-sigma, whatever) codec? bye, -- piergiorgio

Reply by ●July 3, 20082008-07-03

esfield wrote:> Hello, newbie here in need of some help: > > I'm trying to generate white noise. I found a paper online called > "Xorshift RNG's" by George Marsaglia, and found it attractive because of > its simplicity, and its also supposed to generate very good random numbers > that have long periods, pass the diehard randomness tests, etc. > > The problem is, I have a 24-bit codec so I have to shave off 8 bits when I > output the stream as noise. When I look at the signal analysis of the > output, not only are there unacceptable +/-5dB or so variations, but the > energy RISES at 3dB/octave across the spectrum. (???) > > My question is: assuming I have a 32-bit random number generator that is > working properly, should I still see white noise if I only output 24 bits > of that noise? Or will I get the strange behavior described above? > > Any help is much appreciated! >You probably want a Gaussian distribution rather than a rectangular distribution. Try taking the average of blocks of N (where N = say, 16) consecutive samples - this gives a reasonable approximation to Gaussian white noise (see "central limit theorem"). Paul

Reply by ●July 3, 20082008-07-03

esfield wrote:> Hello, newbie here in need of some help: > > I'm trying to generate white noise. I found a paper online called > "Xorshift RNG's" by George Marsaglia, and found it attractive because of > its simplicity, and its also supposed to generate very good random numbers > that have long periods, pass the diehard randomness tests, etc. > > The problem is, I have a 24-bit codec so I have to shave off 8 bits when I > output the stream as noise. When I look at the signal analysis of the > output, not only are there unacceptable +/-5dB or so variations, but the > energy RISES at 3dB/octave across the spectrum. (???) > > My question is: assuming I have a 32-bit random number generator that is > working properly, should I still see white noise if I only output 24 bits > of that noise? Or will I get the strange behavior described above? > > Any help is much appreciated!Whoa! Shift-register random-bit generators output a bit at a time. They are very good at producing a stream of random bits. They are very bad at producing random numbers. (With a shift register, each number is very much like the previous one, just shifted a bit. How about that?!) The best implementation will will use 24 separate random-bit generators and combine their outputs to make up a number. It will probably be sufficient to discard a bunch (about a shift-register's worth) of results every time you use one. You save combining bits to make a number that way. You probably want a 24-bit generator with that approach. Truncating bits reduces the sequence repeat length in a non-obvious way. You might be better off with a linear congruential generator. They aren't as "pure" as parallel XOR shift registers, but one ought to be plenty good for your application. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●July 3, 20082008-07-03

Jerry Avins wrote:> Whoa! Shift-register random-bit generators output a bit at a time. They > are very good at producing a stream of random bits. They are very bad at > producing random numbers. (With a shift register, each number is veryWell, if you get good random bits, then you get also good random numbers.> much like the previous one, just shifted a bit. How about that?!)Only if you, wrongly, read the shift register. What you've to do is to read one bit at time, until you fill your word. For example, read 8 bits to get a random byte, then read *next* 8 bits and so on. Two consecutive bytes are _not_ one a shifted version of the other. bye, -- piergiorgio

Reply by ●July 3, 20082008-07-03

>> My question is: assuming I have a 32-bit random number generator thatis>> working properly, should I still see white noise if I only output 24bits>> of that noise?Yes. The strange behaviour you are seeing is something more complicated. Keep looking! Regards, Steve

Reply by ●July 3, 20082008-07-03

On Jul 3, 12:55 pm, "esfield" <ethanstubblefi...@hotmail.com> wrote:> Hello, newbie here in need of some help: > ... > there unacceptable +/-5dB or so variations > ...If there aren't continuing variations in the average amplitude of finite sets of samples, it isn't a random number generator. Have you measured any variances to evaluate your sample sets? Dale B. Dalrymple

Reply by ●July 3, 20082008-07-03

I've successfully used 32-bit linear feedback shift register as input for high pass filter, that generated white (80%) noise. Just read every bit it outputs and increment your sample if current LFSR bit is set, else decrease it. Be warned, it generates very low frequencies with high amplitude, exceeding 16 bit wave samples.

Reply by ●July 3, 20082008-07-03

On Jul 3, 5:28�pm, Piergiorgio Sartor <piergiorgio.sartor.this.should.not.be.u...@nexgo.REMOVETHIS.de> wrote:> Jerry Avins wrote: > > Whoa! Shift-register random-bit generators output a bit at a time. They > > are very good at producing a stream of random bits. They are very bad at > > producing random numbers. (With a shift register, each number is very > > Well, if you get good random bits, then you get > also good random numbers.i think that needs to be justified. the bits coming out of a maximum- length shift register sequence can be proven to be virtually white (the autocorrelation is a spike at 0 with a small amount of DC). but, unless you do some scrambling of the bits, they make lousy white random numbers.> > much like the previous one, just shifted a bit. How about that?!) > > Only if you, wrongly, read the shift register. > > What you've to do is to read one bit at time, > until you fill your word. > For example, read 8 bits to get a random byte, > then read *next* 8 bits and so on. >so, for 24-bit numbers, you would have the shift register sequence (with XOR-ing in the feedback path) clunk out 24 bits for each pseudo- random number? makes it a little slower than linear congruence. at least if you have a multiplier> Two consecutive bytes are _not_ one a shifted > version of the other.okay, but i dunno if that is what the OP intended. r b-j

Reply by ●July 3, 20082008-07-03

On Jul 3, 8:02�pm, "ionic" <io...@gazeta.pl> wrote:> I've successfully used 32-bit linear feedback shift register as input > for high pass filter, that generated white (80%) noise. Just read every > bit it outputs and increment your sample if current LFSR bit is set, > else decrease it. Be warned, it generates very low frequencies with high > amplitude, exceeding 16 bit wave samples.i think what you have is a virtually white pseudorandom signal getting integrated. then it should be "brown" or "red" or "1/f^2" noise. also, in the LFSR cycle there is one more 1 than there are zeros. integrating that will cause a ramping "DC component". those shift register sequences can be useful, but they have issues. if you want pseudorandom numbers, don't just output the state of the shift registers after one shift and XOR operation. also, if used as a white noise source to determine the response of an alleged LTI system, they work good. if there is non-linearity in the system, that manifests itself as little spikes in the impulse response that aren't really s'posed to be there. a guy named Paul Kovitz (i think that was his name) did a paper for an AES convention in the 90s (or maybe earlier) on how to use 3 different maximum length sequences and then, i think, on a sample-by-sample basis, he picked the median value from the 3 coherent impulse responses. r b-j