[comp.lang.pascal] help on random number generator & tpu display requested

NELIS%NLR.nl@cunyvm.cuny.edu (W.J.M. Nelis, NLR-NOP) (07/18/90)

Hi, I am a recent user (1 month) of TP 5.5.  The first project with TP will
be a discrete event simulator.  I (already) have two problems, both caused
by a lack of information in the manuals:

-1- Which pseudo random number is used by TP?  It is a multiplicative
    linear congruential generator, but I can't determine its parameters.

-2- Is there a utility to display the interface section of a unit? I
    suspect the .DOC file of a .TPU file to be incomplete, but I like to
    check it.

I'd appreciate any help,
  Wim J. M. Nelis
  EARN/BITNET : NELIS@NLR.NL

ftpam1@acad3.fai.alaska.edu (MUNTS PHILLIP A) (07/20/90)

In article <23899@adm.BRL.MIL>, NELIS%NLR.nl@cunyvm.cuny.edu (W.J.M. Nelis, NLR-NOP) writes...
>Hi, I am a recent user (1 month) of TP 5.5.  The first project with TP will
>be a discrete event simulator.  I (already) have two problems, both caused
>by a lack of information in the manuals:
> 
>-1- Which pseudo random number is used by TP?  It is a multiplicative
>    linear congruential generator, but I can't determine its parameters.

     See the article in the October 1988 issue of "Communications of the ACM"
for stuff on random number generators.  Don't use the built-in version.

Philip Munts N7AHL
NRA Extremist, etc.
University of Alaska, Fairbanks

dmurdoch@watstat.uwaterloo.ca (Duncan Murdoch) (07/21/90)

In article <1990Jul19.180723.8770@hayes.fai.alaska.edu> ftpam1@acad3.fai.alaska.edu writes:
>In article <23899@adm.BRL.MIL>, NELIS%NLR.nl@cunyvm.cuny.edu (W.J.M. Nelis, NLR-NOP) writes...
>>-1- Which pseudo random number is used by TP?  It is a multiplicative
>>    linear congruential generator, but I can't determine its parameters.
>
>     See the article in the October 1988 issue of "Communications of the ACM"
>for stuff on random number generators.  Don't use the built-in version.

What problems does the built-in one have?

Duncan Murdoch

ftpam1@acad3.fai.alaska.edu (MUNTS PHILLIP A) (07/22/90)

In article <1990Jul21.115203.2435@maytag.waterloo.edu>, dmurdoch@watstat.uwaterloo.ca (Duncan Murdoch) writes...
>In article <1990Jul19.180723.8770@hayes.fai.alaska.edu> ftpam1@acad3.fai.alaska.edu writes:
>>In article <23899@adm.BRL.MIL>, NELIS%NLR.nl@cunyvm.cuny.edu (W.J.M. Nelis, NLR-NOP) writes...
>>>-1- Which pseudo random number is used by TP?  It is a multiplicative
>>>    linear congruential generator, but I can't determine its parameters.
>>
>>     See the article in the October 1988 issue of "Communications of the ACM"
>>for stuff on random number generators.  Don't use the built-in version.
> 
>What problems does the built-in one have?
> 
>Duncan Murdoch

     Most presently used random number generators have arithmetic overflow
in the internal calculations, which causes strange things to the sequences.
Hence the large body of lore concerning which seeds to use (or not use!).  A
generator without overflow (the article referenced above evades it with 
various clever techniques) will always generate the entire sequence, no matter
what seed you use.  The article is actually pre-5.5, so it is possible that
they have fixed it.

     Last year in a DSP class we did some simulations.  Generators used by
other students included those intrinsic to MS Basic and MS Fortran and generated
noticeably spiky results.  I used the "Minimal Standard Generator" described
in the article and my results were absolutely flat.

     I will append my random number generator unit.

Philip Munts N7AHL
NRA Extremist, etc.
University of Alaska, Fairbanks

UNIT MSRandom;

INTERFACE

  FUNCTION random(VAR seed : longint) : real;

IMPLEMENTATION

(* From CACM Oct 1988 *)

  FUNCTION random(VAR seed : longint) : real;

    CONST
      a = 16807;
      m = 2147483647;

      q = 127773;
      r = 2836;

    VAR
      lo, hi, test : longint;

  BEGIN
    hi := seed DIV q;
    lo := seed MOD q;
    test := a*lo - r*hi;
    IF test > 0 THEN
      seed := test
    ELSE
      seed := test + m;
    random := seed/m;
  END;

END.

mic@sun.soe.clarkson.edu (Mic Lacey) (07/24/90)

This message is empty.

timmins@sun.udel.edu (Steve Timmins) (07/30/90)

Would someone please be kind enough to mail me a function to produce
random numbers relatively reliably?  It is for a MS-Pascal application
(DOS).

Thanks,
	Steve

-- 
Steve Timmins                                      timmins@sun.udel.edu
University of Delaware - 
Academic Computing and Instructional Technology
Newark, Delaware 19716