Score:1

Can I emit a block shorter than internal state of (any) Xorshift PRNG without having to compute the full block?

pf flag

Xorshift family pseudo-random number generators have a variety of different internal state sizes.

Let's take one of this family called xorshift1024*.

My question is:

Having xorshift1024* a internal state of 1024-bits, can I generate a block shorter than 1024-bits without having to compute the entire 1024-bits output before the internal state cycles to the next?

poncho avatar
my flag
Ummmm, have you looked at the implementation on the wiki page you linked to? That would give you the answer...
phantomcraft avatar
pf flag
@poncho Yes, but I don't know how to read C code yet. If you know how to answer, I ask to do it, just an "yes" or "not" for me is enough.
Paul Uszak avatar
cn flag
Note: There is a growing caucus that suggests no one should use C/C++ for new applications. [Rust](https://www.theregister.com/2022/12/09/linux_kernel_61_column/) is now used in phones and the Linux kernel as a safer alternative.
phantomcraft avatar
pf flag
@PaulUszak I like Rust, but honesty, C/C++ is rather portable
Score:1
cn flag

Yes - you virtually always generate a shorter output block than the state. In the case of xorshift1024* you output t * 1181783497276652981 where t is a mangled and iterated variable acting over the internal state array x. That's a 64 bit value, and the return value from that function.

You'll only output state sized blocks for the simplest of this class of generators like xorshift32/64 which feature 32 and 64 bit state sizes respectively.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.