r/AskComputerScience • u/Forsaken-Job-7126 • Jul 01 '26
Since computer can only generate pseudo random numbers
can't you do really cool trick with the fact that if you were to roll a dice 5 times and all the previous rolls were the number 3 normally with true random ness the 6th roll only gets a 1/6 chance of rolling any number. Is that still true with pseudo randomness ? and if so can you prove it
0
Upvotes
View all comments
Show parent comment
3
u/Bubbly_Safety8791 Jul 01 '26
You can put some bounds on that by considering the internal state space of the PRNG. A PRNG whose internal state is a 32bit number is in one of 4 billion states. How many of those states correspond to ones where the preceding n outputs match a particular pattern? If we've been outputting numbers between 1 and 10, say, and the previous three outputs were 6, 6, 6, if it's a decent PRNG, those should correspond to roughly 1/1000 of those possible internal states. So, 4 million or so states. And it seems reasonable then that of those 4 million states, 400,000 or so each probably correspond to each of the next possible outputs 0 thru 9, so yes, we will have learned little about the machine from three digits.
But if we knew the last 9 outputs were 6, 6, 6, 6, 6, 6, 6, 6 and 6... well, there are probably more like only one in a billion states where that is the prior output sequence. So.. the PRNG is in one of four or so possible internal states. Each of those four states will produce a fixed next output - so there's almost certainly no way that all ten digits are possible after nine sixes.
200 outputs is more than enough to pin down the internal state of the machine to a single possible one, if you had a complete oracle of outputs to states