<x-flowed>Hey, does anyone out there know anything about generating random numbers in
ASM code, or perhaps where I can learn more about the theory behind it so I
can write my wn code? I f could just just get someone else's code that of
course would be easier... Thank you.
-Ben
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> Hey, does anyone out there know anything about generating random
> numbers in ASM code, or perhaps where I can learn more about the
> theory behind it so I can write my wn code? I f could just just
> get someone else's code that of course would be easier...
Speakinng of random numbers, I have a new (?) question.
How do I generate random numbers with a nice statical distribution, ie
ones that fit a standard bell-shaped curve. Most random number generators
try to generate all possible combinations in an even distribution, but what
if I want numbers "near" "X", perhaps with a specified standard deviation...
> -----Original Message-----
> From: William Chops Westfield [SMTP:billwKILLspamCISCO.COM]
> Sent: Monday, 8 May 2000 6:26
> To: .....PICLISTKILLspam.....MITVMA.MIT.EDU
> Subject: Re: Generating Random Numbers?
>
> Speakinng of random numbers, I have a new (?) question.
>
> How do I generate random numbers with a nice statical distribution, ie
> ones that fit a standard bell-shaped curve. Most random number generators
> try to generate all possible combinations in an even distribution, but
> what
> if I want numbers "near" "X", perhaps with a specified standard
> deviation...
>
> BillW
It depends if the bell as a crack in it like the liberty bell or it may be
that it's tuned to the 3rd harmonic and I can't tell as I have tinatus
[excuse spelling as spelling checker wants to put in tetanus] from a thread
the other week my ears are still ringing
Regards Art :-)
> How do I generate random numbers with a nice statical distribution,
> ie ones that fit a standard bell-shaped curve. Most random number
> generators try to generate all possible combinations in an even
> distribution
Bill:
There are lots of algorithms, but if you only have a random-sequence
generator that gives an even distribution, you can STILL use it to
create a sequence that has a bell-shaped distribution. Here's one
way:
BELL_RANDOM:
CLRF OUTPUT ;CLEAR THE OUTPUT REGISTER.
MOVLW 100 ;SETUP TO GET 100 EVENLY-DISTRIBUTED
MOVWF COUNT ;RANDOM NUMBERS.
LOOP:
CALL RANDOM ;W = A RANDOM NUMBER.
ANDLW 10000000B ;IS THE HIGH BIT SET?
SKPZ ;IF NOT, SKIP AHEAD.
RETURN ;OTHERWISE, RETURN WITH A "BELL-SHAPED"
;RANDOM NUMBER IN "OUTPUT".
Of course, the above is just an example; it'd be better if your
"RANDOM" routine returned a number in a larger range than [0-255]...
But I'm sure you get the idea, which is that even "flat-distribution"
sequences have properties that can be used to generate a bell-shaped
distribution.
A bell curve (or Gaussian distribution) is easy because if you add together
a large number of random numbers taken from a uniformly-distributed
generator (like the type you describe), you will get some number, call it
x. If you repeat the process with different numbers from that generator and
get x2,x3,x4, etc., then the x's will have a distribution which
approximates a Gaussian. You can then get whatever standard dev. and mean
you want by just scaling and shifting the output. So, if the sequence
x,x2,x3,x4,.... has mean 0.5 and stdev 2, and you want mean=10 and sddev=6,
then the sequence 3*x+9.5,3*x2+9.5,3*x3+9.5,..... will have what you want.
I don't know how many numbers you will need to add together to generate
each output number, but from a some graphs I have in a book here, it looks
like about 10 to 20 would be adequate.
Sean
At 01:25 PM 5/7/00 PDT, you wrote:
>Speakinng of random numbers, I have a new (?) question.
>
>How do I generate random numbers with a nice statical distribution, ie
>ones that fit a standard bell-shaped curve. Most random number generators
>try to generate all possible combinations in an even distribution, but what
>if I want numbers "near" "X", perhaps with a specified standard deviation...
>
>BillW
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7 RemoveMEshb7TakeThisOuTcornell.edu ICQ #: 3329174
I wrote:
>So, if the sequence x,x2,x3,x4,.... has mean 0.5 and stdev 2, and you want
mean=10 and sddev=6,
>then the sequence 3*x+9.5,3*x2+9.5,3*x3+9.5,..... will have what you want.
Which should have been:
3*x+8.5,3*x2+8.5,3*x3+8.5,..... since the original had a mean of 0.5 which
contributes 1.5 when multiplied by 3. Sorry for any confusion.
Sean
At 01:25 PM 5/7/00 PDT, you wrote:
>Speakinng of random numbers, I have a new (?) question.
>
>How do I generate random numbers with a nice statical distribution, ie
>ones that fit a standard bell-shaped curve. Most random number generators
>try to generate all possible combinations in an even distribution, but what
>if I want numbers "near" "X", perhaps with a specified standard deviation...
>
>BillW
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7 spamBeGoneshb7spamBeGonecornell.edu ICQ #: 3329174
You can use PN sequences to generate a random sequence. Use the words
"pseudo-random sequences" or "pseudorandom-number generators" in your web
search. These are outlined in most electronics textbooks on communications
such as those published by Prentice Hall or McGraw-Hill.
PN generators have application in noise generators and spread-spectrum key
generators, etc. Also used to build hardware bit-error-rate generators.
Phil.
On Saturday, May 06, 2000 6:36 PM, Ben R. [SMTP:TakeThisOuTben_r_EraseMEspam_OUTHOTMAIL.COM] wrote:
> Hey, does anyone out there know anything about generating random numbers
in
> ASM code, or perhaps where I can learn more about the theory behind it so
I
> can write my wn code? I f could just just get someone else's code that of
> course would be easier... Thank you.
>
> -Ben
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
Not wishing to sound disheartening, the generation of RN's or even good
PRN's is really tricky. I'd suggest you check out the random number
section of http://www.mathcom.com/nafaq/index.html to source the information you
need.
This is a really, really well trodden field.
Cheers
/Kevin
---
Kevin J. Maciunas RemoveMEkevinTakeThisOuTcs.adelaide.edu.au
Department of Computer Science PH: +61-8-8303-5586
The University of Adelaide FAX:+61-8-8303-4366
Adelaide 5005 South Australia
This is totally correct, generation is not easy! Ask IBM about the
RNDU function that they had. Said it was random, seems that after a period
of time it is not, and a pattern emerges.
If you want some random numbers to put into a lookup table, try to find
those generated by the Random corp
> This is totally correct, generation is not easy! Ask IBM
> about the
> RNDU function that they had. Said it was random, seems that after a
> period
> of time it is not, and a pattern emerges.
> If you want some random numbers to put into a lookup table, try to
> find
> those generated by the Random corp
>
> Dennis
>
>
>
>
> maybe read an input 8 times putting the values into a byte.
>
> might work.. i am not sure.
>
> Andy K
> N1YEW
>
**NO** - this does not generate a random number! The resultant number is
correllated with the inputs. My earlier posting in this thread has a
reference to a wealth of information on what to do/how to do it.
Random numbers are particularly important in cryptography; if you have
any doubts as to the consequences of poor random number selection, look
back to Netscape's original presentation on secure transmission of TCP
data. It took people in the audience about 10 mins to devise a way to
bust it due to the insane choice of "random" number. We should all
listen to history!
/Kevin
--
Kevin J. Maciunas Net: EraseMEkevincs.adelaide.edu.au
Dept. of Computer Science Ph : +61 8 8303 5845
University of Adelaide Fax: +61 8 8303 4366
Adelaide 5005
SOUTH AUSTRALIA