DSPRelated.com
Forums

Random Variable Generation (Newbie).

Started by Deamon November 3, 2010
I am trying to understand how  to generate random numbers. I came
across the following concepts of auto correlation anc Covariance  and
also the power Spectral density using the wiener khichin theorem.
Please can anyone explain this concept and its relevance to a
communication system if any.

Also I know that correlation has to do with how different 2 signals
are from each other  and variance deals with how far a signal from
another signal. I know the formulas statistically but in MATLAB it is
implemented as a combination of ifft and fft  why is this so .

Any pointer to more materials on the web to aid my understanding will
be very much appreciated
>I am trying to understand how to generate random numbers. I came >across the following concepts of auto correlation anc Covariance and >also the power Spectral density using the wiener khichin theorem. >Please can anyone explain this concept and its relevance to a >communication system if any. > >Also I know that correlation has to do with how different 2 signals >are from each other and variance deals with how far a signal from >another signal. I know the formulas statistically but in MATLAB it is >implemented as a combination of ifft and fft why is this so . > >Any pointer to more materials on the web to aid my understanding will >be very much appreciated
What level of quality are you looking for? For many purposes a very quick and simple linear congruel generator is fine. For other purposes, nothing but a cryptographic grade generator, based on sources of demonstrable entropy, will do. Steve
On Nov 3, 3:49&#4294967295;am, "steveu" <steveu@n_o_s_p_a_m.coppice.org> wrote:
> >I am trying to understand how &#4294967295;to generate random numbers. I came > >across the following concepts of auto correlation anc Covariance &#4294967295;and > >also the power Spectral density using the wiener khichin theorem. > >Please can anyone explain this concept and its relevance to a > >communication system if any. > > >Also I know that correlation has to do with how different 2 signals > >are from each other &#4294967295;and variance deals with how far a signal from > >another signal. I know the formulas statistically but in MATLAB it is > >implemented as a combination of ifft and fft &#4294967295;why is this so . > > >Any pointer to more materials on the web to aid my understanding will > >be very much appreciated > > What level of quality are you looking for? For many purposes a very quick > and simple linear congruel generator is fine. For other purposes, nothing > but a cryptographic grade generator, based on sources of demonstrable > entropy, will do. > > SteveThanks
Thanks I just need to understand and a simple random number generator.
On Nov 3, 12:14&#4294967295;am, Deamon <persistence...@gmail.com> wrote:
> On Nov 3, 3:49&#4294967295;am, "steveu" <steveu@n_o_s_p_a_m.coppice.org> wrote: > > > > > > > >I am trying to understand how &#4294967295;to generate random numbers. I came > > >across the following concepts of auto correlation anc Covariance &#4294967295;and > > >also the power Spectral density using the wiener khichin theorem. > > >Please can anyone explain this concept and its relevance to a > > >communication system if any. > > > >Also I know that correlation has to do with how different 2 signals > > >are from each other &#4294967295;and variance deals with how far a signal from > > >another signal. I know the formulas statistically but in MATLAB it is > > >implemented as a combination of ifft and fft &#4294967295;why is this so . > > > >Any pointer to more materials on the web to aid my understanding will > > >be very much appreciated > > > What level of quality are you looking for? For many purposes a very quick > > and simple linear congruel generator is fine. For other purposes, nothing > > but a cryptographic grade generator, based on sources of demonstrable > > entropy, will do. > > > SteveThanks > > Thanks I just need to understand and a simple random number > generator.- Hide quoted text - > > - Show quoted text -
Get the "Mersenne Twister" Homepage here: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html There is a lot of free code and the "twister" is royalty free and it passes muster on most statisitcal tests for randomness. About the only thing to not use it for is cryptographic applications. You may use BlumBlum Shub or RSA for that. If you want a basic intro into pseudo random number generation, look at http://www.nrbook.com/a/bookcpdf.php chapter 7 This book may be downloaded for free and it gives a good base from which to understand. Plus there is code. Have fun Clay

Clay wrote:


> If you want a basic intro into pseudo random number generation, look > at > > http://www.nrbook.com/a/bookcpdf.php chapter 7 > > This book may be downloaded for free and it gives a good base from > which to understand. Plus there is code. > > Have fun > Clay
One can build very simple binary pseudo random numbers like that: x[n+1] = ((x[n] << A) +/- x[n] +/- B ) modulo 2^m This is a linear congruent generator with multiplier = 2^A +/- 1 ; so there is no need for multiply operation. I wonder if anyone already found good combinations of A, B and modulo for this case; and how it compares to the "best" of the known LCGs. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Deamon <persistence911@gmail.com> writes:

> I am trying to understand how to generate random numbers. I came > across the following concepts of auto correlation anc Covariance and > also the power Spectral density using the wiener khichin theorem. > Please can anyone explain this concept and its relevance to a > communication system if any. > > Also I know that correlation has to do with how different 2 signals > are from each other and variance deals with how far a signal from > another signal. I know the formulas statistically but in MATLAB it is > implemented as a combination of ifft and fft why is this so . > > Any pointer to more materials on the web to aid my understanding will > be very much appreciated
I like to use the method presented here to generate a random number: http://xkcd.com/221/ - Kenn
On Nov 3, 1:33&#4294967295;pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> Clay wrote: > > If you want a basic intro into pseudo random number generation, look > > at > > >http://www.nrbook.com/a/bookcpdf.php&#4294967295;chapter 7 > > > This book may be downloaded for free and it gives a good base from > > which to understand. Plus there is code. > > > Have fun > > Clay > > One can build very simple binary pseudo random numbers like that: > > x[n+1] = ((x[n] << A) +/- x[n] +/- B ) modulo 2^m > > This is a linear congruent generator with multiplier = 2^A +/- 1 ; so > there is no need for multiply operation. > > I wonder if anyone already found good combinations of A, B and modulo > for this case; and how it compares to the "best" of the known LCGs. > > Vladimir Vassilevsky > DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
The cases where 2^A +- 1 may prove interesting since you are now working with Fermat and Mersenne primes for some values of A. Usually one needs the coefs to be at least relatively prime for the generated sequence to have maximal length Clay p.s. A big issue with LCM generators is the high degree of sample to sample correlation. This will require some kind of shuffling to make the generators become statistically useful although I'm sure there are some cases where a simple LCM is all that is needed.

Clay wrote:

> On Nov 3, 1:33 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: > >> >>One can build very simple binary pseudo random numbers like that: >> >>x[n+1] = ((x[n] << A) +/- x[n] +/- B ) modulo 2^m >> >>This is a linear congruent generator with multiplier = 2^A +/- 1 ; so >>there is no need for multiply operation. >> >>I wonder if anyone already found good combinations of A, B and modulo >>for this case; and how it compares to the "best" of the known LCGs. > The cases where 2^A +- 1 may prove interesting since you are now > working with Fermat and Mersenne primes for some values of A. Usually > one needs the coefs to be at least relatively prime for the generated > sequence to have maximal length > > Clay > > p.s. A big issue with LCM generators is the high degree of sample to > sample correlation. This will require some kind of shuffling to make > the generators become statistically useful although I'm sure there are > some cases where a simple LCM is all that is needed.
I needed very fast software PRNG for the purpose of dithering, so I tried LCGs with 2^n +/- 1 multipliers. The deficiencies of LCGs are clear if you look at the spectrum. I took the flatness of the spectrum as the criteria. As expected, A = 2^n - 1 doesn't make for good sequencies. A = 2^n + 1 is better, but it is still worse then the best possible selection. If we make LCG modulo 2^16 and limit A and B to 8 bits, then: 1) A = 181, B = 19 is the best generator through all numbers. 2) A = 5, B = 255 is the best generator with A = 2^n + 1. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com