Issue using random streams

I have a project where I need to make a repeatable set of randomized parameters based on an incrementing main number.

I’m using random streams but I’m finding that as I increase the main number the results generated by the streams also increase. For eg if I try to generate a random integer in range from 0-100 using a stream based on the main number the random integers get higher as the input number does.

Any ideas on how to prevent this? I’d like for there to be an equal chance at the whole range of random results each time, so there is no correlation between the main number and the numbers I’m getting out for the parameters in the scene.

Can you show your code?

Sure - something like this for eg. I’m making scenes with randomized physics based meals :sweat_smile:, the ‘food number’ increases by one for each new scene generated. I want to use this number as a seed to randomize all the other aspects of the scene.

I had hoped a different initial seed would result in an entirely random different stream each time (as it does in other software) but this doesn’t seem to be the case.

use stream
set stream

Ok, and from now until you want the next stream, you use the upper part of the code? ( I have to check because almost everyone doesn’t seem to understand this :slight_smile: )

That’s how it should work.

Maybe try jumping the seed in 10s or 100s etc?

1 Like

Ok thanks - multiplying the seed by 100 seems to work!

For anyone who might come across this in future I’ve attached the results of a generated random int from a stream, using both a seed that increments by one each time and then that seed *100.

1 Like

Ok wait - it’s not working! Going a little further and the results don’t seem to be random, nearly every result occurs at least twice. Surely this can’t be expected behavior?

stream results 2

You will get numbers occurring more than once. It’s not a selection list. Theoretically, one number could occur 100 times.

Yes theoretically they could all be the same, but the odds of getting almost every number occurring at least twice with this setup are really miniscule?

Let me try more numbers.

1 Like

The odds of getting several numbers more than once is very high.

Several certainly, but 16 out of 20 being duplicates or triplicates when it’s out of 100?

Sorry, it’s not clear what your table represents.

How many samples do you take for each seed?

The seed used is on the left column, the random integer generated (in a range of 0-100) is in the middle column and the number of times the generated result occurs is on the right column.

It’s just one sample per seed because they’ll always be the same.

So you’re just taking the first number in the stream for each seed?

I’m just checking, you’re starting like this?

and not


Sorry - wasn’t super clear. Here’s what’s effectively happening separated off.

Each time the scene is stup I’m incrementing the seed (but later I’d be using an input seed in order to recall the scene with the same setup), setting the stream from this seed * 100 and then for the purposes of testing collecting a random int in the range of 0-100.

1 Like

These are histograms of the first few seeds

They are about as flat as you could expect, I think, and they are always identical over generations, for each seed.

1 Like

Weird - I don’t know why we are getting different results. I went up to 50 and it continues for me to be mostly duplicates.

Here’s the first 100 seeds ( left to right a higher bar means that number occurred more )

Isn’t you getting a 2 or 3, just the same as my



I have no doubt that different streams will produce different results - the weird thing is the result from the single stream.

I think you are getting random results because you are setting the stream with a random seed each time? Instead of the seed following a pattern?