Talk:Pseudo-random numbers/PCG32: Difference between revisions

Line 18:
==The Pseudocode==
 
Well it is'nt really is it? The purpose of pseudocode is to clearly explain the algorithm. It doesn't does it? Let me look at method seed. It starts by setting state to zero and inc to (seed_sequence << 1) | 1. It then calls next_int() which performs some calculating and returns a value which seed ignores. Strange but wait a sec next_int() has an undocumented side effect it changes the value of state to in this case to inc. seed now adds seed_state to state and calls next_int() again ignoring the return result. The side effect this time is to set state to inc*6364136223846793005+inc. Should not all this be replaced with satate<-((inc+seed_state)*6364136223846793005+inc ? see [http://www.rosettacode.org/wiki/[Van_Eck_sequence#Python:_Composition_of_pure_functions]] and many others for examples of coding in python without relying on side effects. Those who have copied this without thought should be ashamed of themselves!!!--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 14:04, 13 August 2020 (UTC)
 
:The link mentions this code: https://github.com/imneme/pcg-c-basic/blob/master/pcg_basic.c for the algoroithm which has these side effects.
Line 34:
 
:::: I'll take that as a concession that 7 lines of new code is indeed shorter than 11 lines of new code, and that declarative definitions are indeed simpler than messy recipes, more or less scrupulously followed, but not always very reliable, or very deeply understood :-) [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 16:29, 14 August 2020 (UTC)
 
::::: I just have to say that I find [[Van_Eck_sequence#Python:_Composition_of_pure_functions]] completely unintelligible, plus it is about 500 times slower (100,000 in 45s) than [[Van_Eck_sequence#Python:_Using_a_dict]] (1,000,000 in under 1s). --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 09:57, 15 August 2020 (UTC)
7,796

edits