piclist 2000\05\10\043111a >
Thread: Pseudorandom number generation on a PIC
www.piclist.com/techref/microchip/math/index.htm?key=random
flavicon
face BY : Robert A. LaBudde email (remove spam text)



<x-flowed>If all that is wanted is a small run length of pseudorandom numbers, this
can be accomplished by the following 8-bit multiplicative-additive
congruential generator:

       X(n+1) = [27 X(n) + 3]  mod 256
              = [16 X(n) + 8 X(n) + 2 X(n) + X(n) + 3]  mod 256
              = [32 X(n) - 4 X(n) - X(n) + 3] mod 256

with    X(0) = 27.

The output of this sequence should appear as reasonably 'white' noise.

Note that 16 X(n) is X(n) shifted left 4 bits with zero fill, etc., and mod
256 is simply accomplished by disregarding overflow bits and keeping only
the low order 8 bits of the addend.

I would presume that a linear shift register algorithm would give superior
run length and spectral properties for the same computation time. I'll try
to dredge up a validated one and post it to the list.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: EraseMEralspam_OUTspam.....lcfltd.com
Least Cost Formulations, Ltd.                   URL: http://lcfltd.com/
824 Timberlake Drive                            Tel: 757-467-0954
Virginia Beach, VA 23464-3239                   Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

</x-flowed>
<4.2.2.20000510041749.00d7acf0@mailhub.exis.net>

In reply to: <Pine.LNX.4.10.10005100800140.177-100000@prof.pmmf.hu>
See also: www.piclist.com/techref/microchip/math/index.htm?key=random

Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Pseudorandom number generation on a PIC

month overview.

new search...