# [Help] Smoothing Out Random Functions

I looking for some help on the RAND expression. I’m wanting a picture(s) to randomly show up after the watch wakes. I’ve used the RAND function, but the generator is a rotating number that changes each (?) millisecond. So having an image display is tricky to keep it on the screen for a predetermined time period. See the following face I created:

I have 6 picture frames that cycle as an animation. Periodically I want 1 of 2 other pictures to show up for approx 1/3-1/2 seconds. I used the following condition in the transparency field:

\$(rand(0,50))=0?100:0\$

Basically when the RAND number is 0 it will display the image. Problem is it is only for one split second. What else could I do to keep the image up for longer than 1 MS?

If I keep an expression that uses RAND multiple time in a single element, will each RAND generate independently? For instance will RAND(1,1) - RAND(0,100) = 0 all the time?

I’ve tested individual elements with RANDs and each one is independent: tr0n09 - So Random - watch face for Apple Watch, Samsung Gear S3, Huawei Watch, and more - Facer

@eradicator09, should fuel the coulrophobist amongst us

Looks like nobody really helped with this problem. It’s been a long time since you posted it but the random face is still only popping up for a millisecond so I’m assuming you didn’t figure it out. I’m still new at this whole coding thing but I’ve been messing with the random today trying to understand it better. One thought I had was making there a range of numbers that allow it to be visible. Like this…

\$(rand(0,50))<=25?100:0\$

So really all I added was a less than symbol 25. This makes it “possible” to stay on the screen longer if the next random number happens to be 25 or less. The downside to this method is its going to flicker a lot. If you change the range from 1,500 and <=100 then it will flicker less but there is less change for it to be on the screen for very long. You might be able to play with the numbers and find a range that works for what you were hoping to achieve.

I have a question for you though if you don’t mind. I tried creating 3 objects and put this in the X axis.

(wakeRand(0,320))

I was thinking that this would put the 3 different objects in 3 different locations. I also tried putting the wakeRand expression into the transparency tab and all 3 objects had the same transparency.

This tells me that when the watch wakes there is only 1 random number drawn no matter how many objects are using the same code. I tested this with the stRand function as well and I get the same result. It’s a different value then the wakeRand value but all the stRand objects value all remain the same. Do you know of any way to make them have different values?

Not at the moment. I have a design I leave in draft mode to test the same thing. My one thought would be to use the interpaccel function to slow the movement of a rand() function. I just haven’t had time to test.

A square wave could be the answer. By plugging in rand() as the period and combining it with a sine and some math it might be tweaked to produce short periods of positives in longer periods of negatives. Use this in a conditional and you should be good. I’ll see if I can produce a proof of concept later on.

I don’t know anything about what szandor said but I did practice using the wakeRand
(InterAccel(#DWE#,wakeRand(…etc.
I still ended up with the same effects. I believe if you do that then yes you can get it to flash for the time period you want however it’s either going to show once or not if using wakeRand. Not sure what would happen if you used normal rand.