(unknown charset) Re: [BLACKBOX] Random Number Tests

From: (unknown charset) Oleg N. Cher <"Oleg>
Date: Tue, 18 Nov 2008 12:46:14 +0200

----boundary-LibPST-iamunique-344180329_-_-
Content-type: text/plain

Helmut,
also there is a pseudorandom generator.


(* From M.Raiser, N.Wirth "Programming in Oberon" *)
MODULE RandomNumbers;

VAR z: LONGINT;

PROCEDURE Uniform*(): REAL;
  CONST
    a = 16807; m = 2147483647;
    q = m DIV a; r = m MOD a;
  VAR gamma: LONGINT;
BEGIN
  gamma:=a*(z MOD q) - r*(z DIV q);
  IF gamma>0 THEN z:=gamma
  ELSE z:=gamma+m
  END;
  RETURN z*(1.0/m)
END Uniform;

PROCEDURE InitSeed*(seed: LONGINT);
BEGIN
  z:=seed;
END InitSeed;

BEGIN
  z:=314159;
END RandomNumbers.


If you want to get really random numbers
(not pseudo), must be used timer.
For example, PROCEDURE WinApi.GetTickCount()

--
 Oleg N. Cher
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-344180329_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTFcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEhlbG11dCxccGFyDQphbHNvIHRoZXJlIGlzIGEg
cHNldWRvcmFuZG9tIGdlbmVyYXRvci5ccGFyDQpccGFy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1lc3NhZ2Ugd2l0
aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBMSVNUUy5PQkVST04uQ0hccGFy
DQp9
----boundary-LibPST-iamunique-344180329_-_---
Received on Tue Nov 18 2008 - 11:46:14 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:51 UTC