[Python-ideas] Re: Enhancing variable scope control

2022-12-06 Thread Jeremiah Gabriel Pascual
> . . . > ... for _var in list(globals()): > . . . > ... exec(f"del {_var}", globals()) > . . . > ...globals()... There's a more complicated solution that uses only the locals that requires getting the previous frame and using `ctypes.pythonapi.PyFrame_LocalsToFast`, b

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Alex Prengère
@Chris Indeed the true figure, if my math is correct, is a bit under 5.98 because of the "non-independence" of triplets. I computed it and found 5.382, so finding 6 is entirely normal. For the details: calling L = 600 and n = 3 * number of possible sequence of L digits: 10^L * if a specific digit

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Benedict Verhegghe
I used a brute force method to check the probability. Counted the number of triples in 600 random numbers 0-9, repeated that 1 times and took the mean: 5.99 So it looks like Chris's number is more accurate. Benedict Op 6/12/2022 om 09:25 schreef Alex Prengère: @Chris Indeed the true figure

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Benedict Verhegghe
The difference is probably because I count 4 repeated values as 2 triples, etc..., while the 5.382 value counts them only once? Benedict Original Message From: Benedict Verhegghe Sent: Tuesday, December 6, 2022 at 10:38 UTC To: python-ideas@python.org Subject: [Python-ideas] R

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Chris Angelico
On Tue, 6 Dec 2022 at 21:39, Benedict Verhegghe wrote: > > I used a brute force method to check the probability. Counted the number > of triples in 600 random numbers 0-9, repeated that 1 times and took > the mean: 5.99 > So it looks like Chris's number is more accurate. Calling my number "mo

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Alex Prengère
Yes, I ran a simulation where 4 repeated values are not counted as 2, and found something close to 5.38. There is also a slight inaccuracy in my formula when counting repeated values that are (or not) at the beginning/end of the sequence. Le mar. 6 déc. 2022 à 11:54, Benedict Verhegghe a écrit :

[Python-ideas] Re: Better (?) PRNG

2022-12-06 Thread Wes Turner
> google/paranoid_crypto has a number of Randomness Tests: > google/paranoid_crypto has a number of Randomness Tests in Python IIR > From grep '^#' > https://github.com/google/paranoid_crypto/blob/main/docs/randomness_tests.md > : > > ```md > # Randomness tests > ## Goal of the tests > ## Non-goal

[Python-ideas] Re: Better (?) PRNG

2022-12-06 Thread James Johnson
Thanks On Tue, Dec 6, 2022 at 10:39 AM Wes Turner wrote: > > google/paranoid_crypto has a number of Randomness Tests: > >> google/paranoid_crypto has a number of Randomness Tests in Python IIR >> From grep '^#' >> https://github.com/google/paranoid_crypto/blob/main/docs/randomness_tests.md >> :

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Steven D'Aprano
Thanks for posting your code, but at 178 lines (most of which are either commented out or irrelevent to your question) its a hard slog to work out what you're doing. And as for the seemingly endless sequence of "Random number ... Value entered", what did information did you think we would get f

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-06 Thread Steven D'Aprano
On Tue, Dec 06, 2022 at 07:58:09PM -0500, David Mertz, Ph.D. wrote: > You have an error in the code you posted. You never use R2 after one > call to SystemRandom. Ah so I do, thanks for picking that up! James, see how *easy* it is for experts to notice bugs, at least some of them, in a short p

[Python-ideas] Re: Better (?) PRNG

2022-12-06 Thread Matthias Görgens
On Tue, 15 Nov 2022 at 00:14, David Mertz, Ph.D. wrote: > In general, all PRNGs are deterministic, and by relying on a known seed, > the Nth element in a sequence of random numbers can always be > reconstructructed. However, if a large number of random numbers are used, > certain replication sce

[Python-ideas] Re: Better (?) PRNG

2022-12-06 Thread David Mertz, Ph.D.
For background, Random123 was developed for a supercomputer that does molecular dynamic simulations. In particular, for the Anton supercomputer, complete reproducibility of simulations was/is an important constraint. In concept, in that context, you might want to "jump to timestamp 1 billion, and