COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Random Variable Generation (Newbie).

• Follow

```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
```
 0
Reply Deamon 11/3/2010 3:01:14 AM

```>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
```
 0
Reply steveu 11/3/2010 3:49:18 AM

```On Nov 3, 3:49=A0am, "steveu" <steveu@n_o_s_p_a_m.coppice.org> wrote:
> >I am trying to understand how =A0to generate random numbers. I came
> >across the following concepts of auto correlation anc Covariance =A0and
> >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 =A0and 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 =A0why 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.

```
 0
Reply Deamon 11/3/2010 4:14:26 AM

```On Nov 3, 12:14=A0am, Deamon <persistence...@gmail.com> wrote:
> On Nov 3, 3:49=A0am, "steveu" <steveu@n_o_s_p_a_m.coppice.org> wrote:
>
>
>
>
>
> > >I am trying to understand how =A0to generate random numbers. I came
> > >across the following concepts of auto correlation anc Covariance =A0an=
d
> > >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 =A0and 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 =A0why 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 qui=
ck
> > and simple linear congruel generator is fine. For other purposes, nothi=
ng
> > 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

```
 0
Reply Clay 11/3/2010 2:34:07 PM

```
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.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com

```
 0

```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
```
 0
Reply Kenn 11/3/2010 7:59:32 PM

```On Nov 3, 1:33=A0pm, 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=A0chapter 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] =3D ((x[n] << A) +/- x[n] +/- B ) modulo 2^m
>
> This is a linear congruent generator with multiplier =3D 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.
>
> 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.

```
 0
Reply Clay 11/3/2010 9:13:53 PM

```
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.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com

```
 0

7 Replies
148 Views

(page loaded in 0.12 seconds)

Similiar Articles:

7/10/2012 8:35:58 AM