Random Seed

Hard for me to believe that nobody has asked for a random seed before but I can’t find any such question. How can I seed random number generators? In particular, random noise generators. Do I have to write my own to achieve this? You can SORT OF get random noise generators to “seed” by using another dimension as a place to seed in - i.e., if you have a 1 dimensional simplex noise and you’re selecting at x=0 then you can introduce another dimension and change y which will change the x output but if you’ve got a lot of seeds they will be spread closely enough along the Y axis that they’ll start to correlate. It’s hard for me to believe that there is no seed pin available but that seems to be the case…

doesn’t RandomSpread have a seed input?

Yes, RandomSpread does but I don’t want RandomSpread which is essentially a shuffle so far as I can tell. I’m trying to come up with a patch which demonstrates a need for Seed in Random but am realizing, perhaps a bit late, that my usual programming bias where routines are not always “hot” and where Random number generators inevitably have a seed may have caused me to speak too soon. Still working on such a patch.

Interesting question by the way

I added mscorlib (System and System.Runtime as well) from .NET assemblies and tried to create a random with seed and noticed that there is no random with seed. Am I doing something wrong, or is it being hidden from me for some reason?

image

Well, I finally got around to making what I want. I guess the real question is whether I reinvented the wheel here.
image
I ended up using a RandomSpread because it seems to be the closest thing that has a seed. The problem is when you use RandomSpread you have to know the number of random numbers desired whereas I want a function that gives a new random number each time you ping it no matter how many times that is and if you use the same seed you’ll get the same random numbers generated. So I generate 300 numbers at a time and each next steps through those 300 until they’re exhausted at which point the seed for the random spread is incremented and we generate 300 more ints which we start walking through. Reset goes back to the beginning. One slight problem is that the 300th random of seed i is the first random of seed i+1. One possibility is to not worry about this since seeds should typically be pretty random and making this sort of comparison is unlikely to have an impact. Another is making the block size bigger at the expense of more memory. Another would be to multiply the output of the DivMod by some largish number.
SeededRandom.vl (16.5 KB)

FUSE has a random with seed (it does a lot of things in a way that make more sense to me than standard VVVV actually ;-) ).
It also has a toggle for one-shot-random so you don’t need a cache for it.

Cheers,

Tom

1 Like

It’s great for Fuse but if you want to get a repeatable stream of ints not so great. Big thanks for the pointer though!

Absolutely, I agree.
I just hope VL will take a lot of hints from FUSE generally ;-)

Like usable noises and a random that is more complete and doesn’t need as much boilerplate etc.
Coming from Houdini, a lot of it feels rather clumsy.

@darrellp thanks for bringing this up. has been on the list since ages but weirdly enough you seem to be the first asking for it. so finally latest 6.0 previews include a new (stateful) Random node with Seed input. the other (stateless) Random nodes are now marked with the advanced aspect.

@yar the random class is System.Runtime.dll. if in your screenshot you click the “Create” entry you should get the option to choose the constructor with seed input.

1 Like

Awesome.
I was also irritated by it, but didn’t write a thread for it since I use Fuse mostly anyway… ;-)

@joreg Please check again
seems to be some kind of bug

random_seed_bug

To be honest, it’s not the first time I’ve come across this, but it’s pretty hard to write about on the forum every time.


image

works on my end

I don’t understand what’s going on.
Steps I follow:

  1. Adding the .net framework assembly:
    1.1 System.Runtime
    1.2 mscorlib (just in case)
  2. Browse Random (External, yellow folder)
  3. Click on Random
  4. Select Create.
  5. The Create node will be created, but without any options.

files

What I’m doing wrong?

that is indeed very weird.
following your steps in a fresh vl document makes Create [Seed] show up as second option for me. no matter if I add System.Runtime or mscorlib or both.

however, what is the second option in your screenshot? ‘Random’ category and Create [Object]?

And it’s really very strange. I have installed version 6, the stable version. And now with Create > Random I can create a seed version.

BUT! When I try to do this in preview versions (latest 6.0-0325), the behaviour is the same - nodes are created without any options.

Could it be that you have some settings that differ between vvvv stable and previews? Those are independent from each other.

1 Like

@sebescudie you are absolutely right

random_seed_issue

Thanks, it was enabled for some reason. And seems to be a very dangerous setting