What's the best way to index into a PRNG sequence? #12395
-
Given a sequence as A below, how do I get the ith element of the sequence without resplitting and indexing? One idea I had was to use fold-in, and then I can reproduce the ith element by folding in i. Is there any downside to folding in integers into a generator instead of splitting it?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
We had precisely the example
If anything, there are possible advantages for working memory. |
Beta Was this translation helpful? Give feedback.
-
Hey, adding a question - I imagine something like: for i in range(3):
sk = random.fold_in(k, i)
for j in range(3):
sksk = random.fold_in(sk, j)
print(f"k={k}, i={i}, sk={sk}, j={j}, sksk={sksk}") Which gives sensible output:
|
Beta Was this translation helpful? Give feedback.
We had precisely the example
B
in mind forfold_in
usage. I would go with that!If anything, there are possible advantages for working memory.