Is there a way can set the seed of a random number generator?

Hi,
In my snap! program, I used the pick random number function. And while testing my program i faced a bug which i found hard to repeat because i used the pick random function.
I realized that if we have a way to set the seed of a random number generator in snap! it would be helpful to reproduce the bugs and also testing our code will be easy.
My question is, is there a way to set the seed of the random number generator in snap! ?
Thank you for your help.
Best Regards,
Nisar

I didn't find a way so I made one for a project

ProjectName=seededRandomExample

Needs JS as it uses a bitwise AND block

But now I've a bit of time I'll try and write a pure Snap! one :slight_smile:

Algorthim was one I found on wikipedia

Non JS bitwise AND version using Brian's binary/decimal conversion reporters

ProjectName=seededRandomExampleNoJS

So, with this are we guaranteed to get the same sequence whenever we execute our project ?
Also, a seed will help even in machine learning when we want to shuffle the training data in an order that is repeatable.

100% guaranteed :slight_smile:
As long as your computer chips don't get corrupted by a passing neutrino of course :slight_smile:

I created it for exactly the same reason as you - to provide a known sequence during testing/debugging but then you can just give it a Snap! random number as the seed when you want it be unpredictable

Thanks a lot! I will use it in my code.
Best Regards,
Nisar

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.