Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Random Numbers

0 views
Skip to first unread message

Lee J. Weiner

unread,
Sep 4, 1998, 3:00:00 AM9/4/98
to
In article <6rvf8u$p...@news3.force9.net>, "Scott G. Rhodes" <ad...@raanet.force9.co.uk> wrote:
>I'd like the computer to choose a random number between 1 and 50. Does
>anybody know how or if this can be done in visual basic 4.

iRandom = Int(Rnd * 50) + 1

Lee Weiner
weiner AT fuse DOT net

Andrew

unread,
Sep 5, 1998, 3:00:00 AM9/5/98
to
How random are the so called random numbers generated from a computer
using any of the programming languages. Doesn't the computers design
affect the "randomness" because the whole esence of a computer is to
be structured and organised. Isn't the part of the computer that
contains "numbers" already organised in such a way that it affects the
"randomness" of those numbers???

Reply by email would be much appreciated

Andrew

Barney Laurance

unread,
Sep 5, 1998, 3:00:00 AM9/5/98
to
On Sat, 05 Sep 1998 15:06:28 GMT, ajd...@pipemedia.co.uk (Andrew)
wrote:

>How random are the so called random numbers generated from a computer
>using any of the programming languages.

Not very. They are actualy called 'psudo random numbers', as they are
mathematicaly generated from the previous number, called the seed.
VB's randomize function will set the seed acording to the clock,
making them unpredictable enough for most pourpeses, but not for
cryptography.

/---------------------------------------------\
|Barney Laurance bar...@redmagic.dircon.co.uk |
|www.redmagic.dircon.co.uk/barney/ |
\---------------------------------------------/

Joe We are Borg Foster

unread,
Sep 5, 1998, 3:00:00 AM9/5/98
to

> How random are the so called random numbers generated from a computer

> using any of the programming languages. Doesn't the computers design

It varies.

> affect the "randomness" because the whole esence of a computer is to
> be structured and organised. Isn't the part of the computer that
> contains "numbers" already organised in such a way that it affects the
> "randomness" of those numbers???

Perhaps, but there are plenty of sources of true randomness, especially
if you have a sound card or are connected to a LAN. Anyway, this sort
of thing is discussed in detail in any good algorithms book.

--
Joe Foster <mailto:jfo...@ricochet.net> Spam is irrelevant. Assimilate this:
<ftp://ftp.microsoft.com/softlib/index.txt> Microsoft's master patch list
<ftp://ftp.microsoft.com/softlib/mslfiles/> MS I got yer patch right here!
<http://www.microsoft.com/msdn/> MS Knowledge Base & more
<http://www.dejanews.com/home_ps.shtml> Usenet search and archival engine
<http://www.altavista.digital.com> WWW *and* Usenet search engine
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!

Mark Gregory

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
If you precede your Rnd function with Randomize (in VB6 at least) is seeds
the Rnd function with a base number that comes from the system date/time. I
don't know how far into the date/time it goes for the number but if it goes
as far as the day, I would think this would produce a different set of
numbers each time.

Mark Gregory

Andrew wrote in message <35f152b2...@news.pipemedia.net>...


>How random are the so called random numbers generated from a computer
>using any of the programming languages. Doesn't the computers design

>affect the "randomness" because the whole esence of a computer is to
>be structured and organised. Isn't the part of the computer that
>contains "numbers" already organised in such a way that it affects the
>"randomness" of those numbers???
>

Ben Crain

unread,
Sep 8, 1998, 3:00:00 AM9/8/98
to

Andrew wrote:

> How random are the so called random numbers generated from a computer
> using any of the programming languages. Doesn't the computers design
> affect the "randomness" because the whole esence of a computer is to
> be structured and organised. Isn't the part of the computer that
> contains "numbers" already organised in such a way that it affects the
> "randomness" of those numbers???
>
> Reply by email would be much appreciated
>
> Andrew

As some respondents have noted, random numbers are really pseudo-random,
not perfectly random in the strictest mathematical sense. However, what
degree of "accuracy" do you need? I'm developing an application that,
among other things, generates a "random" path for stock prices, given a
few parameters entered by the user (a trend term, a volatility
term,etc.). Calculating the path requires numerous "drawings" of a random
number drawn from a standard normal distribution. From the equation
governing the path, the theoretical expected value and variance of the
final point can be derived. The program generates a large number of
paths, collects the final results, calculates the empirically observed
mean and variance, and compares them to the theoretical mean and
variance. It also calculates 90% theoretical confidence intervals, and
counts the frequency with which the generated paths actually end up within
those intervals. The "goodness" of the empirical results (how close they
are to the theoretically predicted results) depends solely on VB's random
number generator (and, or course, the number of sample paths). If I
generate 1000 sample paths, and the theoretical expected value of the
stock price is 50, the empirical mean typically turns out to be something
like 50.1, 49.9, etc, and often much better. Something like 90.1 or 89.9%
(or better) of the paths really do wind up within the 90% theoretical
confidence intervals. Moreover, with 100,000 paths the results are much,
much better. For my purposes, that is more than good enough. But I could
imagine applications for which VB's random number generator might not be
adequate. All depends on how good "good" has to be!


Francis Woolfe

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to

> Andrew wrote:
>
> > How random are the so called random numbers generated from a computer
> > using any of the programming languages.

certain deterministic mathematical systems (which can therefore be
implemented by a computer) give rise to "chaos" - they are nonperiodic and
a small change in the initial parameters of the system can give rise to
important changes in the state after a certain period of time.

If you wanna try one of these out try plotting the graph of a sequence
whose first term is, say, .54321 and whose nth term 2x² - 1 where x is the
(n-1)th term. You can try
kx² - 1 for other values of k as well. VB probably looks to some adress in
ram for the equivalent of .54321 - called the random seed - which starts
the whole thing off. Whatever happens to be in that adress is used.

see ya from francis :-)

Peter Diehr

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to
I have an IBM publication, C20-8011 (copyright 1959), entitled "Random
Number Generation and Testing". It goes over the "power residue method",
which is a linear congruential generator. This is the technique most
commonly used. The booklet analyzes this method as to various statistical
qualities: uniform distribution, independence of successive values,
autocorrelation coefficient, etc. While this method passes these tests, it
is well known that the method fails for certain classes of k-dimensional
applications ... this is because there are correlations between k-th
successive values, where k depends upon the initial seed, and the specific
congruence polynomial.

There is a tremendous literature on this topic; you can look in any
numerical analysis text, or just search the www for "pseudorandom" ... I got
3564 hits on Yahoo! just now.

BTW, this type of algorithm is extremely fast: just multiply, add, shift,
and you're done!

Best Regards, Peter

Francis Woolfe wrote in message <01ba7e11$51d27200$7315eec3@default>...

0 new messages