Frequency spectrum of PRN from LFSR 2007-12-13 16:59:07 Read any (appropriate) text book, and it will describe generating pseudo random numbers from linear feedback shift registers.You can find suitable feedback configurations to give maximum length sequences in many books too. As long as you don't pick the one that locks it, the seed doesn't matter.I've tried this, both for 16 bits and 19 bits, and for some reason I can't make it workas I expect. I get a maximum length sequence, uniform PDF, single spike autocorrelation, but non-flat frequency response. It is 10dB higher at low frequencies than high frequencies.Any idea what I might be doing wrong?Cheers,David.

Frequency spectrum of PRN from LFSR Reply #1 – 2007-12-13 17:10:24 Maybe the problem lies in your spectral analysis. Are you properly windowing and overlapping the data? Maybe your 10dB low frequency boost is caused by the impulse generated by a rectangular window? Have you tried a 'natural' noise source to see if you're seeing the same thing?

Frequency spectrum of PRN from LFSR Reply #2 – 2007-12-14 10:26:58 Thanks for the hint benski, but it wasn't the window.It was something even more silly, which I realised in the bath this morning(!).I will share it in case anyone else ever makes the same mistake...For 8-bits of dither, I was just grabbing the bottom 8 bits of the LFSR. On the next clock, I was doing the same. So I only had one new bit each time!This meant each dither sample was equal to the previous, multiplied (or divided) by 2, plus a small (or large) noise signal (i.e. the new bit). You could look at it as an IIR filter with noise at the input, and noise added to the output. The frequency response of this inner filter is what I was seeing.Clocking the LFSR 8 times per 8-bit sample gives me 8 new bits each time, and solves the problem.Cheers,David. Last Edit: 2007-12-14 10:32:45 by 2Bdecided

Frequency spectrum of PRN from LFSR Reply #3 – 2007-12-20 10:52:09 Bit independence is a major deal for cryptography people, who use many methods for testing PRNGs for "true randomness". It's probably overkill for an audio dither generator, but it's nonetheless interesting to look at the methods and quality measures used in the cryptography community (a starting point can be this or this or this). Last Edit: 2007-12-20 10:56:45 by ilo

Frequency spectrum of PRN from LFSR Reply #4 – 2007-12-20 10:58:07 Very interesting, thank you!Cheers,David.

Frequency spectrum of PRN from LFSR Reply #5 – 2010-01-06 16:00:18 Quote from: 2Bdecided on 2007-12-14 10:26:58Thanks for the hint benski, but it wasn't the window.It was something even more silly, which I realised in the bath this morning(!).I will share it in case anyone else ever makes the same mistake...For 8-bits of dither, I was just grabbing the bottom 8 bits of the LFSR. On the next clock, I was doing the same. So I only had one new bit each time!This meant each dither sample was equal to the previous, multiplied (or divided) by 2, plus a small (or large) noise signal (i.e. the new bit). You could look at it as an IIR filter with noise at the input, and noise added to the output. The frequency response of this inner filter is what I was seeing.Clocking the LFSR 8 times per 8-bit sample gives me 8 new bits each time, and solves the problem.Cheers,David.David,Just to confirm again, the valid random number every 8 cycles? Besides, how do u relate few bits of change will have effect on the freq response? Can you explain it?thanks

Frequency spectrum of PRN from LFSR Reply #6 – 2010-01-06 19:55:07 Something you might also consider is the dual form of the LFSR, where instead of taking 'n' bits and xoring them into the first, you take the last bit and XOR it into the appropriate bits in the shift register. While it's been a long, long time since I did this, it is possible to make a shift register from this that changes more bits at a time. For that kind of register, you want to choose a complex, as opposed to simple, polynomial for the register, though.There is also a hardware form I used to use that used two parallel registers and a bunch of XOR's that gave very, very nice results at one tick per value. As I write this, I must say that I also realize I built this in 1977, and I can't remember a (*&(*& thing except that it was published somewhere and it worked like a charm for sequences of length 2^15 -1 ... Sorry.

Frequency spectrum of PRN from LFSR Reply #7 – 2010-01-06 20:48:22 Quote from: 2Bdecided on 2007-12-13 16:59:07I've tried this, both for 16 bits and 19 bits, and for some reason I can't make it workas I expect. I get a maximum length sequence, uniform PDF, single spike autocorrelation, but non-flat frequency response. It is 10dB higher at low frequencies than high frequencies.David, you should post the picture of your spectrum.One possible explanation is the fact that random numbers are unsigned, i.e. have a DC offset. Last Edit: 2010-01-06 20:48:37 by Alexey Lukin

Frequency spectrum of PRN from LFSR Reply #8 – 2010-01-07 10:25:07 1st post = 13th December 2007.@jasonkee111,If you are using it in the simple way I was, and you want an N-bit output, then you need to clock the LFSR N times per output. Otherwise the consecutive outputs are not independent*. They may be sufficiently independent with fewer than N clocks per output, but there's this obvious problem if you reduce it to 1 clock per output.* - I know it's not really independent mathematically, but in the time- and frequency domains the samples look sufficiently independent for normal use.Cheers,David.