Tommi Prami 130 Posted April 28, 2021 Could someone point into nice implementation? Would be nice (but not 100% necessary) that would have similar functionality than RTL version have. More than less drop in replacement (Easy to port) -Tee- Share this post Link to post
David Heffernan 2345 Posted April 28, 2021 What properties are you looking for. The reason that there are many different algorithms in use is that different applications have different requirements. Share this post Link to post
Tommi Prami 130 Posted April 28, 2021 For now, I am open to all suggestions 🙂 Just need to get random numbers and have some Randomize-functionality. As long it is way better tna build in RTL version. If can use it to replace RTL version in code, way or other, I am happy 🙂 -Tee- Share this post Link to post
David Heffernan 2345 Posted April 28, 2021 I don't get this. If you don't have any particular needs, then I don't see how anybody can offer suggestions. And if all you want is a list of libraries, then websearch will get you that. Do you know what you are going to do with these random numbers? Share this post Link to post
aehimself 396 Posted April 28, 2021 Both XOrShift and ISAAC has nice Delphi implementations. They are both PRNGs but it you initialize them with the Random function, they will work quite well. Share this post Link to post
Tommi Prami 130 Posted April 28, 2021 3 hours ago, David Heffernan said: I don't get this. If you don't have any particular needs, then I don't see how anybody can offer suggestions. And if all you want is a list of libraries, then websearch will get you that. Do you know what you are going to do with these random numbers? I just need random numbers that have better quality than stock Random() function in the RTL. I think that is valid requirement. -Tee- Share this post Link to post
Lars Fosdal 1792 Posted April 28, 2021 Don't know about good PRNGs, but get your seeds here. https://www.random.org/ 1 Share this post Link to post
Fr0sT.Brutal 900 Posted April 28, 2021 Any crypto library should have strong PRNG Share this post Link to post
Anders Melander 1784 Posted April 28, 2021 35 minutes ago, Tommi Prami said: I just need random numbers that have better quality than stock Random() function in the RTL. I think that is valid requirement. Yes it is, but if you can't define what "better quality" is then your request is meaningless. In any case, like David said, a web search should give you plenty of candidates. Did you try that first? 3 Share this post Link to post
KodeZwerg 54 Posted April 28, 2021 How about BCryptGenRandom from Windows Api? Is that random/quality enough for your needs @Tommi Prami ? Share this post Link to post
Lars Fosdal 1792 Posted April 28, 2021 @KodeZwerg That's not portable, though - and the quality of the PRNG would depend a lot on the parameters to BCryptOpenAlgorithmProvider. Share this post Link to post
Wagner Landgraf 43 Posted April 28, 2021 7 hours ago, Tommi Prami said: I just need random numbers that have better quality than stock Random() function in the RTL. I think that is valid requirement. -Tee- What is the problem about the current one? What makes it "low quality"? 2 Share this post Link to post
aehimself 396 Posted April 28, 2021 (edited) program Project2; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; Const MAX_NUMBER = 1000; CYCLECOUNT = Integer.MaxValue; Var numbers: Array[0.. MAX_NUMBER - 1] Of Integer; a, min, max: Integer; begin Randomize; For a := Low(numbers) to High(numbers) Do numbers[a] := 0; For a := 1 To CYCLECOUNT Do Inc(numbers[Random(MAX_NUMBER)]); min := CYCLECOUNT; max := 0; For a := Low(numbers) To High(numbers) Do Begin If numbers[a] < min Then min := numbers[a] Else If numbers[a] > max Then max := numbers[a]; End; WriteLn('After ' + CYCLECOUNT.ToString + ' cycle(s), minimum amount of occurrences of the same number is ' + min.ToString + ', maximum is ' + max.ToString); ReadLn; end. After 2147483647 cycle(s), minimum amount of occurrences of the same number is 2144157, maximum is 2150811 That means, the luckiest random number was hit 6654 times more than the least lucky one (from more than 2 billion attempts!). Delphi's internal random number generator has a healthy dispersion. It's not perfect, but it is more than enough for average use. Edited April 28, 2021 by aehimself Share this post Link to post
julkas 12 Posted May 1, 2021 (edited) On 4/28/2021 at 10:28 AM, Tommi Prami said: Could someone point into nice implementation? Would be nice (but not 100% necessary) that would have similar functionality than RTL version have. More than less drop in replacement (Easy to port) -Tee- OK, it depends. Anyway, I suggest - xoshiro / xoroshiro generators Or 🙂 start with simple SplitMix64 Efficiently Generating a Number in a Range Edited May 1, 2021 by julkas Share this post Link to post
Guest Posted May 2, 2021 If you have €1800/yr you can go /n software (IpWorks + SecureBlackbox). No sources 😞 Share this post Link to post
Tommi Prami 130 Posted May 3, 2021 (edited) OK, Let me try again, any reasonably fast, Free and OpenSource implementation of good Random number generator algorithm, that is tested statistically to give better randomness than Stock RTL one.. I have no knowledge on which algorithm is best for what, that is why I am asking. I have an impression that Mersenne twisters are not suggested anymore. As mentioned above xoshiro / xoroshiro generators I have heard are good. But again, have no idea how to choose better one. I would not ask if I had all needed info 🙂 -Tee- Edited May 3, 2021 by Tommi Prami Share this post Link to post
Mike James 1 Posted May 3, 2021 There's always... https://software.intel.com/content/www/us/en/develop/articles/intel-digital-random-number-generator-drng-software-implementation-guide.html Regards, Mike. Share this post Link to post
Anders Melander 1784 Posted May 3, 2021 Since we're now in full bike-shed mode here's my contribution: https://hackaday.io/project/4628-nuclear-random-number-generator A random number generator based on radioactive decay. 1 Share this post Link to post
Stefan Glienke 2003 Posted May 3, 2021 pcg32 should be easy enough to implement from the c code. Share this post Link to post
aehimself 396 Posted May 3, 2021 1 hour ago, Anders Melander said: Since we're now in full bike-shed mode here's my contribution: https://hackaday.io/project/4628-nuclear-random-number-generator A random number generator based on radioactive decay. Holy crap this is awesome! Imagine shrinking this to a hardware key 😄 Share this post Link to post
Anders Melander 1784 Posted May 3, 2021 19 minutes ago, aehimself said: Holy crap this is awesome! Imagine shrinking this to a hardware key 😄 Just as random, almost as cool, and has a slightly smaller risk of invoking a visit from Homeland Security: https://www.orau.org/ptp/collection/consumer products/dudice.htm A dice made of depleted uranium 🙂 Anyway, it is possible to get USB-sized true randomness, just without the coolness factor. For example: https://www.amazon.com/TrueRNG-V3-Hardware-Random-Generator/dp/B01KR2JHTA/ref=pd_sbs_1 Share this post Link to post
Bob Devine 11 Posted May 3, 2021 Some that look interesting - I haven't investigated these in detail so can't give any opinions on them. The CodeProject ones would need to be ported. https://github.com/LUXOPHIA/Random https://www.codeproject.com/Articles/1083372/Random-Number-Generator-Recommendations-for-Applic https://www.codeproject.com/Articles/1190459/Randomization-and-Sampling-Methods https://www.codeproject.com/Articles/5272482/Partially-Sampled-Random-Numbers-for-Accurate-Samp 1 Share this post Link to post
David Heffernan 2345 Posted May 3, 2021 14 hours ago, Tommi Prami said: OK, Let me try again, any reasonably fast, Free and OpenSource implementation of good Random number generator algorithm, that is tested statistically to give better randomness than Stock RTL one.. I have no knowledge on which algorithm is best for what, that is why I am asking. I have an impression that Mersenne twisters are not suggested anymore. As mentioned above xoshiro / xoroshiro generators I have heard are good. But again, have no idea how to choose better one. I would not ask if I had all needed info 🙂 -Tee- You have already had numerous suggestions that meet all your requirements. Share this post Link to post
Tommi Prami 130 Posted May 4, 2021 (edited) On 5/3/2021 at 5:46 PM, Anders Melander said: Since we're now in full bike-shed mode here's my contribution: https://hackaday.io/project/4628-nuclear-random-number-generator A random number generator based on radioactive decay. You got good Delphi implementation of that 😄 Edited May 4, 2021 by Tommi Prami Share this post Link to post