Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Miscellaneous
»
Suggestions
»
Replace Mersenne Twister PRNG?
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Hello! Anything new?
by
Fibonacci
[
Today
at 09:19:11 am]
could Ardour's YTK be use...
by
robert rozee
[
Today
at 08:26:10 am]
Questions about TFuncSeri...
by
hedgehog
[
Today
at 08:19:43 am]
Update a table with an Au...
by
Zvoni
[
Today
at 08:08:47 am]
Configuration issues rega...
by
Martin_fr
[
Today
at 08:05:38 am]
How many lines is too man...
by
440bx
[
Today
at 07:05:21 am]
[SOLVED] TCP/IP Question
by
valdir.marcos
[
Today
at 05:03:12 am]
Update fpexprpars
by
valdir.marcos
[
Today
at 04:52:27 am]
C/C++ code to Object Pasc...
by
Curt Carpenter
[
Today
at 03:58:28 am]
Win 11, strange position ...
by
d7_2_laz
[March 08, 2026, 11:13:04 pm]
Lazarus for Windows on aa...
by
msintle
[March 08, 2026, 09:23:01 pm]
Lazarus Bugfix Release 4....
by
Martin_fr
[March 08, 2026, 08:17:00 pm]
Debian removes FPC/Lazaru...
by
Schmitty2005
[March 08, 2026, 07:56:33 pm]
[SOLVED] ??? I don't even...
by
n7800
[March 08, 2026, 07:29:19 pm]
how to rename/save a seco...
by
valdir.marcos
[March 08, 2026, 07:25:59 pm]
Set horizontal scroll pos...
by
rvk
[March 08, 2026, 07:17:42 pm]
How to run an external co...
by
valdir.marcos
[March 08, 2026, 07:07:31 pm]
Qt6/Wayland clipboard: pa...
by
Fred vS
[March 08, 2026, 07:02:05 pm]
NIL vs. Assign: when to u...
by
valdir.marcos
[March 08, 2026, 06:22:05 pm]
lazarus in new england
by
valdir.marcos
[March 08, 2026, 06:10:02 pm]
Text Fill (Memo)
by
Sc0li0sis
[March 08, 2026, 02:36:32 pm]
[Closed]Canvas.StretchDra...
by
jamie
[March 08, 2026, 01:57:10 pm]
Amigo programming languag...
by
paxscript
[March 08, 2026, 12:21:59 pm]
[SOLVED] The "dockedforme...
by
jamie
[March 08, 2026, 10:50:42 am]
The Case For Pascal, 55 Y...
by
valdir.marcos
[March 08, 2026, 08:02:58 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Replace Mersenne Twister PRNG? (Read 3344 times)
segfault
Full Member
Posts: 107
Replace Mersenne Twister PRNG?
«
on:
April 27, 2020, 10:28:59 am »
FP currently uses the Mersenne Twister random number generator, which although commonly used, has disadvantages :
https://en.wikipedia.org/wiki/Mersenne_Twister#Disadvantages
A suggested alternative is the ACORN family of PRNG's, which is apparently easy to code, fast, and has better statistical properties than the Mersenne twister (it passes the tests which twister fails).
Wiki page :
https://en.wikipedia.org/wiki/ACORN_(PRNG
)
Also the authors web site :
http://acorn.wikramaratna.org/index.html
Note : it's not cryptographically secure, but neither is the twister.
«
Last Edit: April 27, 2020, 10:31:00 am by segfault
»
Logged
Thaddy
Hero Member
Posts: 18765
To Europe: simply sell USA bonds: dollar collapses
Re: Replace Mersenne Twister PRNG?
«
Reply #1 on:
April 27, 2020, 12:17:01 pm »
There already many alternatives (see the wiki) but if I can find C sources I will add it, depending on licensing,
ETA
The period is rather low compared to others. I wonder if it really adds something.
https://wiki.freepascal.org/Marsaglia%27s_pseudo_random_number_generators
(these are really fast). I added tests fror correctness.
https://wiki.freepascal.org/Delphi_compatible_LCG_Random
https://wiki.freepascal.org/Dev_random
Note that FPC is not likely to change its default random because it would break existing code and data.
Same goes for Delphi, therefor I added a Delphi compatible LCG to the wiki to be able to work with Delphi generated data.
Note I already have a pluggable framework like C++, but I need to verify some modules. Comes later this year.
«
Last Edit: April 27, 2020, 12:51:02 pm by Thaddy
»
Logged
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...
BeniBela
Hero Member
Posts: 958
Re: Replace Mersenne Twister PRNG?
«
Reply #2 on:
April 27, 2020, 12:50:13 pm »
I have implemented xoshiro**:
https://github.com/benibela/internettools/blob/master/data/xquery.internals.rng.pas
The inventor of this prng claims it is faster than others
Logged
https://www.benibela.de/index_en.html
https://github.com/benibela
Thaddy
Hero Member
Posts: 18765
To Europe: simply sell USA bonds: dollar collapses
Re: Replace Mersenne Twister PRNG?
«
Reply #3 on:
April 27, 2020, 12:54:09 pm »
Have have implemented that too (128). It is faster than most with nice properties.
It also belongs to the Marsalia family in the sense that it uses the same concepts: it derives from xorshift.
I may add it to the Marsalia article.
Logged
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Miscellaneous
»
Suggestions
»
Replace Mersenne Twister PRNG?
TinyPortal
© 2005-2018