[comp.sys.amiga] Random Number Generation

bryanc@haddock.ima.isc.com (Bryan Cote) (01/05/90)

Simply, does anyone have any suggestions on the best way to generate random
values on the amiga? I am using a public domaine c compiler and have yet
to find a library call to generate random numbers. I've been reading this 
newsgroup on and off for a year or so but don't recall seeing this discussed.
Any help will be greatly appreciated, thanks!

------------------------------------------------------------------------------

martens@navajo.cis.ohio-state.edu (Jeff Martens) (01/05/90)

See "Random Number Generators:  Good Ones are Hard to Find," by Steve
Park and Keith Miller, CACM, 10/88.  There was more discussion in a
"Technical Correspondence" section of a recent "Communications."
-=-
-- Jeff (martens@cis.ohio-state.edu)

Anybody know where I can get a phone with a backspace key?

asaph@TAURUS.BITNET (01/07/90)

In article <15579@haddock.ima.isc.com> bryanc@haddock.ima.isc.com (Bryan Cote) w
>
>Simply, does anyone have any suggestions on the best way to generate random
>values on the amiga? I am using a public domaine c compiler and have yet
>to find a library call to generate random numbers. I've been reading this
>newsgroup on and off for a year or so but don't recall seeing this discussed.
>Any help will be greatly appreciated, thanks!
>
>------------------------------------------------------------------------------

The following program uses a random number generator described in
communications of the ACM. It is considered a good one. If anyone
is interested I might be persuaded to look up the exact issue and
author.

#define ARAND   16807
#define MRAND   2147483647
#define QRAND   127773
#define RRAND   2836

long RandomSeed;

long Random()
{
  long lo,hi,test;
  hi = RandomSeed/QRAND;
  lo = RandomSeed%QRAND;
  test = ARAND*lo + RRAND*hi;
  if (test>0) RandomSeed = test;
  else RandomSeed=test+MRAND;
  return(RandomSeed);
}

main(argc,argv)
int argc;
char *argv[];
{
  int l;
  long r;
  if (argc != 2) printf("usage: rand <seed>\n");
  else {
    RandomSeed = atol(argv[1]);
    for (l=0; l<500; l++) {
      r = Random();
      printf("%d) %ld %ld\n",l,r,r%2);
    }
  }
}

                                                Asaph
asaph@taurus.bitnet                             asaph@math.tau.ac.il

david@ms.uky.edu (David Herron -- a slipped disk) (01/08/90)

Try, _The_Art_Of_Computer_Programming_ volume 2 (3?) _Semi-Numerical_
_Algorithms_ by D. Knuth.

You may have a bit of trouble finding it nowadays now that the bookstores
are only carrying help guides for PC-DOS trashy software..  But it's
highly recommended regardless.

-- 
<- David Herron; an MMDF guy                              <david@ms.uky.edu>
<- ska: David le casse\*'      {rutgers,uunet}!ukma!david, david@UKMA.BITNET
<- 
<- New official address:  attmail!sparsdev!dsh@attunix.att.com

martens@bowling.cis.ohio-state.edu (Jeff Martens) (01/08/90)

In article <13614@s.ms.uky.edu> david@ms.uky.edu (David Herron -- a slipped disk) writes:
.Try, _The_Art_Of_Computer_Programming_ volume 2 (3?) _Semi-Numerical_
._Algorithms_ by D. Knuth.

.You may have a bit of trouble finding it nowadays now that the bookstores
.are only carrying help guides for PC-DOS trashy software..  But it's
.highly recommended regardless.

It's a little dated in places, but very well-written, and a good place
to start (there's a lot to be said for classics).  Any library worthy
of the title will have at least one copy of the entire series.
-=-
-- Jeff (martens@cis.ohio-state.edu)

Anybody know where I can get a phone with a backspace key?

hasker@m.cs.uiuc.edu (01/08/90)

> /* Written  5:27 pm  Jan  6, 1990 by asaph@TAURUS.BITNET in m.cs.uiuc.edu:comp.sys.amiga */
> /* ---------- "Re:Random Number Generation" ---------- */
> 
> The following program uses a random number generator described in
> communications of the ACM. It is considered a good one. If anyone
> is interested I might be persuaded to look up the exact issue and
> author.
> 
> 

The reference is CACM Oct 1988, p. 1192.  The routine is supposed to be
very portable, does not overflow, and has a full cycle length.


Rob Hasker			University of Illinois at Urbana-Champaign
hasker@cs.uiuc.edu		{uunet|convex|pur-ee}!uiucdcs!hasker

trantow@csd4.csd.uwm.edu (Jerry J Trantow) (01/08/90)

In article <75316@tut.cis.ohio-state.edu> Jeff Martens <martens@cis.ohio-state.edu> writes:
>
>See "Random Number Generators:  Good Ones are Hard to Find," by Steve
>Park and Keith Miller, CACM, 10/88.  There was more discussion in a
>"Technical Correspondence" section of a recent "Communications."
>-=-
>-- Jeff (martens@cis.ohio-state.edu)
>
Also look back through the 89 IEEE-ASSP.  There was an article this fall
that gave 68000 ASM routines for fast random number generation.
_____________________________________________________________________________
Jerry J. Trantow          | When wealth is lost,
1560 A. East Irving Place | nothing is lost,
Milwaukee, Wi 53202-1460  | When character is lost,
(414) 289-0503            | All is lost.
_____________________________________________________________________________

keithh@atreus.uucp (Keith Hanlan) (01/09/90)

In article <15579@haddock.ima.isc.com> bryanc@haddock.ima.isc.com (Bryan Cote) writes:
>
>Simply, does anyone have any suggestions on the best way to generate random
	Find a book called "Numerical Recipes". It gives you a discussion
	of the issues, the algorithms, and even the code (Fortran,Pascal,
	and, I think in the recent editions, C).

	I have the first edition and think it is a great book.
	Unfortunately, it's at home so I can't give you the ISBN or
	publisher.

	Keith
Keith Hanlan
Bell-Northern Research, Ottawa, Canada 613-765-4645
uunet!utgpu!bnr-vpa!bnr-fos!bmers58!atreus!keithh or keithh@bnr.ca

bdb@becker.UUCP (Bruce Becker) (01/09/90)

In article <75373@tut.cis.ohio-state.edu> Jeff Martens <martens@cis.ohio-state.edu> writes:
>In article <13614@s.ms.uky.edu> david@ms.uky.edu (David Herron -- a slipped disk) writes:
>.Try, _The_Art_Of_Computer_Programming_ volume 2 (3?) _Semi-Numerical_
>._Algorithms_ by D. Knuth.
>[...]

	I would be interested to find a used copy
	of this book.

Thanks,
-- 
  \\\\	 Bruce Becker	Toronto, Ont.
w \66/	 Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
 `/v/-e	 BitNet:   BECKER@HUMBER.BITNET
_<  \_	 "Head-slam me, Jesus, on the turnbuckle of life" - Godzibo

GWO110%URIACC.BITNET@brownvm.brown.edu (F. Michael Theilig) (01/09/90)

On 5 Jan 90 04:36:39 GMT you said:
>
>See "Random Number Generators:  Good Ones are Hard to Find," by Steve
>Park and Keith Miller, CACM, 10/88.  There was more discussion in a
>"Technical Correspondence" section of a recent "Communications."

     Amiga Transactor ran an article called "Random, or just Confused?" by
 David Wood in Volume 1, Issue 2  (June, 1988).

     /*   F. Michael Theilig               GWO110 at URIACC.Bitnet

            "There is no Dark Side in the Moon, really ...
                                  matter of fact it's all dark."       */

martens@bowling.cis.ohio-state.edu (Jeff Martens) (01/09/90)

There's an article in the latest CACM (Jan or Feb '90) on implementing
the minimal standard RNG that may be worth checking out.
-=-
-- Jeff (martens@cis.ohio-state.edu)

Anybody know where I can get a phone with a backspace key?

840445m@aucs.uucp (Alan McKay) (01/10/90)

In article <1161@bmers58.UUCP> keithh@atreus.UUCP (Keith Hanlan) writes:
>In article <15579@haddock.ima.isc.com> bryanc@haddock.ima.isc.com (Bryan Cote) writes:
>>
>>Simply, does anyone have any suggestions on the best way to generate random
>	Find a book called "Numerical Recipes". It gives you a discussion
>	of the issues, the algorithms, and even the code (Fortran,Pascal,
>	and, I think in the recent editions, C).
>
>	I have the first edition and think it is a great book.
>	Unfortunately, it's at home so I can't give you the ISBN or
>	publisher.
>
>	Keith
>Keith Hanlan
>Bell-Northern Research, Ottawa, Canada 613-765-4645
>uunet!utgpu!bnr-vpa!bnr-fos!bmers58!atreus!keithh or keithh@bnr.ca

Numerical Recipes in C  --- ISBN 0-521-35465-X
published by cambridge university press.

Yes, it is an exellent book!

P.S. Hi Keith
-- 
+ Alan W. McKay       +  VOICE: (902) 542-1565                        +
+ Acadia University   +  "Courage my friend, it is not yet too late   +
+ WOLFVILLE, N.S.     +   to make the world a better place."          +
+ 840445m@AcadiaU.CA  +                    - Tommy Douglas            +