First time here? Check out the FAQ!
x

I want a to "seed" a randomWalkStartingFrom or have a NextRandomWithSeed start at value "0"

0 votes
682 views
Hopefully this will be easy...? ;-)

I want to "seed" a randomWalkStartingFrom: 0 so that I can make it repeatable.

Or ... have a NextRandomWithSeed that always outputs "0" as a starting value, when the sound starts playing in a timeline. (Is there a non "brute force" trial & error method to find seeds for nextRandomWithSeed that will do this?)

The CapyTalk expression will go into variable box to control the morphing of a sound.
asked Dec 6, 2020 in Capytalk & Smalltalk by mark-phillips (Adept) (1,220 points)

3 Answers

0 votes
If you use the expession

0.2 s tick randomWalkStartingFrom: 0 stepSize: 0.1 reset: !Reset

it will return to 0 each time !Reset becomes 1. For use in a Timeline, you could try:

0.2 s tick randomWalkStartingFrom: 0 stepSize: 0.1 reset:  (!LocalTime lt: 0.2)

This will change the value of the reset argument from 1 to 0 over the course of 0.2 s (which you could adjust to match whatever the update clock rate is (right now it is set to 0.2 s tick)

Does that work for your purposes?
answered Dec 6, 2020 by ssc (Savant) (128,160 points)
Not really ... I guess I wasn't clear. I only want the random stream of numbers to *start* at zero ... (just once at the beginning). I don't have any desire to "reset" and start from zero at any other point in time. That much I can do already with "randomWalkStartingFrom: 0" And that works just fine. But I would also like the random stream of numbers to be (at least somewhat) repeatable (as with a seed), so that I can chose a seed such that the values are consistently closer to 1 at a certain point in the future. But I see no easy way to do that with a randomWalkStartingFrom: 0 ... since apparently there is no way to seed that process. (am I correct?)

Meanwhile I'd be fine just using nextRandomWithSeed, IF I could just knew a way to ensure that the first random number output will be "0" (or at least very close) and that after wandering around it (eventually) hovers near to "1"  around  40" to 50" later (after that I don't much care what happens). I can't think of anyway to do *that* other than to randomly chose a seed, run the process over and over, eliminating seeds that don't generated a stream of numbers with those two criteria. I don't fancy myself doing that. If there was a way to start a nextRandomWithSeed at zero, I'd be willing to try a few seeds to see if I could stumble onto one that meets my 2nd much looser and more forgiving criteria. But I can't imagine trying that approach with two criteria to satisfy.

I'm beginning to think I will simply have to resort to creating an array that ensures that my two criteria are met.
+1 vote

You can send the message seededWith: to any random expression. So for example, you could use:

(0.1 s tick randomWalkStartingFrom: 0 stepSize: 0.1 reset: 0) seededWith: 12345678

which starts at 0 and drunkenly walks toward 0.265 in about 8 seconds (so you could multiply the whole thing by 4 to make sure it gets up to 1).

If, instead, you want random numbers that start near zero, then get larger over time and reach 1 at a specific time, you could add random jitter to a straight line. For example, in:

| up down |
up := 1 ramp: 10 s.
down := 1 - (1 ramp: 10 s).
up * (1 + ((0.1 s random) * down))

the variable up is a line that goes from 0 to 1 in 10 seconds. The variable down starts at 1 and ends up at 0 by 10 seconds. Then you add some random jitter to the basic shape of up. The amount of jitter you are adding starts at the maximum and shrinks over time so that, by 10 s, you have no jitter and will really land on 1.

If you end up experimenting with these, please let us know which one gets closest to what you have in mind and what tweaks you added to get there.

Thanks!

answered Dec 7, 2020 by ssc (Savant) (128,160 points)
Thanks. Ah ... so just adding seededWith: (some number). at the end of all the other criteria for the "drunken" walk should get the job done ... after a little trial and error on finding a suitable seed.

But I like the other idea too very slick ... I've definitely had instances where something like that would be helpful. Thanks!
0 votes

Another idea is something like this:

The feedback loop creates a correlated signal that provides a bit more of that walk like effect.  Play with the noise scale and corralation amount to get feel you want.  To deal with the zero at the start, you could either add a sign or max value to ensure the value starts at zero.  By default, that signal flow there is likely to dip below zero for first few steps but there are other ways to fiddle with that part including adding a small ramp to the centervalue offset so that it bias a bit above zero and then moves quickly down to zero 

Here is an example kym

http://kyma.symbolicsound.com/qa/?qa=blob&qa_blobid=11823503768899578634

answered Dec 8, 2020 by ben-phenix (Practitioner) (440 points)
edited Dec 8, 2020 by ben-phenix
Thanks. I'll give it a try when I get back on Kyma.
Thanks, Ben!
BTW, if anyone is curious to hear what a random walk sounds like at the audio rate, check out the prototype "Noise (Brownian or Random walk)".
(To find it, you can use Ctrl+B and search for "random walk").
...