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

→‎The Pseudocode: Further link.
(→‎The Pseudocode: Further link.)
Line 19:
 
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.
(Ps, if this is an answer to my earlier section then it may need to be a sub-header). --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 20:04, 13 August 2020 (UTC)
Anonymous user