Hi, How can we do a random number, with a seed? -- Tomas Kral <thomas.kral@email.cz>
Am 22.03.2019 um 19:52 schrieb Tomas Kral <thomas.kral@email.cz>:
Hi,
How can we do a random number, with a seed?
Either with „atmospheric noise“ on https://www.random.org/ or you implement your own, e.g. start here: https://en.m.wikipedia.org/wiki/Pseudorandom_number_generator ;) Cheers, Oliver
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Tomas Kral Sent: Friday, 22 March 2019 6:52 PM To: Oberon@lists.inf.ethz.ch Subject: [Oberon] SystemV - Random Number
Hi,
How can we do a random number, with a seed?
See Chapter 2 'A first Oberon program' in 'Programming in Oberon - Steps Beyond Pascal and Modula' by Reiser and Wirth. You will have to make a couple of changes to the code if you want to compile it with Oberon-07. Regards, Chris Burrows CFB Software http://www.astrobe.com/RISC5/
Chris: if this work is done with the FPGA, it is also possible to use the firmware to generate a pseudo-random number sequence. See Xilinx Application Note XAPP884 (v1.0) January 10, 2011, "An Attribute-Programmable PRBS Generator and Checker" by Daniele Riccardi and Paolo Novellini. They provide both the VHDL and Verilog implementations, a rudimentary discussion, and references. You can find XAPP884 by searching Xilinx. Another good source of information is Chill by Robert Campbel, available from Component Pascal Collection.
How can we do a random number, with a seed?
See Chapter 2 'A first Oberon program' in 'Programming in Oberon - Steps Beyond Pascal and Modula' by Reiser and Wirth. You will have to make a couple of changes to the code if you want to compile it with Oberon-07.
See Chapter 2 'A first Oberon program' in 'Programming in Oberon - Steps
Hi, thanks for multitude of answers, I will start with this one. Also I can vaguely remember there was some side effect property of RISC5 FPGA code, that acted as a reasonable seed or fairly random values on its own, cannot remember though where it was mentioned. -- Tomas Kral <thomas.kral@email.cz>
I take Oberon.Time() as initial seed. Jörg Am 23.03.2019 um 11:09 schrieb Tomas Kral <thomas.kral@email.cz>:
See Chapter 2 'A first Oberon program' in 'Programming in Oberon - Steps
Hi, thanks for multitude of answers, I will start with this one.
Also I can vaguely remember there was some side effect property of RISC5 FPGA code, that acted as a reasonable seed or fairly random values on its own, cannot remember though where it was mentioned.
-- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Tomas Kral wrote:
See Chapter 2 'A first Oberon program' in 'Programming in Oberon - Steps
Hi, thanks for multitude of answers, I will start with this one.
Some time ago I ported module RandomNumbers to Oberon-07 and added a few extra procedures. You can find my implementation here: https://github.com/hansklav/Oberon-07/blob/master/Random.Mod <https://github.com/hansklav/Oberon-07/blob/master/Random.Mod> -- Hans Klaver
Hans iso 16807 (=7^5) it‘s recommended to use 48271 (prime) Jörg
Am 23.03.2019 um 16:22 schrieb Hans Klaver <hklaver@dds.nl>:
Tomas Kral wrote:
See Chapter 2 'A first Oberon program' in 'Programming in Oberon - Steps
Hi, thanks for multitude of answers, I will start with this one.
Some time ago I ported module RandomNumbers to Oberon-07 and added a few extra procedures. You can find my implementation here: https://github.com/hansklav/Oberon-07/blob/master/Random.Mod
-- Hans Klaver -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Jörg Straube wrote:
I.s.o. 16807 (=7^5) it's recommended to use 48271 (prime)
Some time ago I ported module RandomNumbers to Oberon-07 and added a few extra procedures. You can find my implementation here: https://github.com/hansklav/Oberon-07/blob/master/Random.Mod <https://github.com/hansklav/Oberon-07/blob/master/Random.Mod> Jörg, thanks for the suggestion. I changed my module Random accordingly.
-- Hans Klaver
With an FPGA being available, and perhaps depending on the application, another option would be to implement a feedback shift register. But as Knuth said, "Random numbers should not be generated with a method chosen at random".
I.s.o. 16807 (=7^5) it's recommended to use 48271 (prime)
I'd be interested to know exactly why, without reading all the literature ;-)
https://github.com/hansklav/Oberon-07/blob/master/Random.Mod
Nice. Thanks! Paul
You could take my RandomNumbers.Mod or program your own 😀 Jörg
Am 22.03.2019 um 19:52 schrieb Tomas Kral <thomas.kral@email.cz>:
Hi,
How can we do a random number, with a seed?
-- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Basically, I coded a Lehmer (Park Miller) pseudo random number generator (PRNG) https://en.m.wikipedia.org/wiki/Lehmer_random_number_generator#Parameters_in... Lehmer PRNGs are special cases of LCGs: https://en.m.wikipedia.org/wiki/Linear_congruential_generator I took n = 2^31-1 and g = 48271 br Jörg
Am 23.03.2019 um 00:47 schrieb Jörg <joerg.straube@iaeth.ch>:
You could take my RandomNumbers.Mod or program your own 😀 Jörg
Am 22.03.2019 um 19:52 schrieb Tomas Kral <thomas.kral@email.cz>:
Hi,
How can we do a random number, with a seed?
-- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
participants (8)
-
chris@cfbsoftware.com -
Hans Klaver -
Jörg -
Jörg Straube -
Paul Reed -
Skulski, Wojciech -
Till Oliver Knoll -
Tomas Kral