Seed for Expr Random?

Holland Hopson's icon

I use expr's random function, and I'd like to seed it to produce predictable random number sequences. I can't find a seed function in the expr docs. Is there one? Or do I need to switch to the vanilla random object, jit.noise, etc.?

Jeremy's icon

Hi Holland, AFAICT there's no way to seed expr's random(). It's a nice idea, though. expr is still using the bad old random algorithm we've abandoned for our other objects, by the way -- you'll get "better" random sequences using random (which now supports floats and ranges like the expr object, in case that's why you're using expr for this).

Wil's icon

Wow @Jeremy - who knew to look at the "new" tab in random object help file!? Greatness!

Jeremy's icon

Yeah, looks like we left these changes off of the release notes! Sorry about that.

The other (IMO really useful) addition is that seed is now an attribute, so if you like what you got with a randomly-generated seed, you can figure out what it is and preserve it for the next time.

👽'tW∆s ∆lienz👽's icon

seed is now an attribute

that is sweet! (always wondered, if i didn't seed specifically, how i could access what the exact seed was when simply instantiating the default object)


(now we just need 'urn' and 'random' objects to combine into one 😁 ...just kidding...)

...Thank You for this improved 'random' object 🥹

Holland Hopson's icon

Thanks @Jeremy. I didn't know the new random supported floats and ranges, which was exactly why I turned to expr so many years ago. Time to update my abstractions!