Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Weighted Random?

  • Posted by Darryl Torke on October 4, 2013 at 7:37 pm

    Hi, forgive the ambiguous subject. What I have is a pre-composition of different ‘flickers’, and in the main composition I have the pre-comp time remapped and the expression: random(10) on the precomp, making it randomly pick frames. The effect is nice, but what I’d ideally like is for the frames on the front end of the precomp to be picked more often then the back end – some parabolic ratio or anything really. Basically I’d like the randomness of the expression picking frames at the end of the precomp very very rare, and at the start of the comp rather common.

    Does his make sense?

    Thank you for your time.

    Kevin Camp replied 12 years, 7 months ago 3 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    October 4, 2013 at 11:32 pm

    something like this should load the deck in favor of lower numbers.

    r = random(10);
    (r*r*r/100);

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Darby Edelen

    October 8, 2013 at 4:56 am

    Alternatively if you want to have a value you can modify easily to change the weighting you could do something like this:

    weight = 3;
    max = 10;

    max * Math.pow(random(), weight);

    When weight is equal to 1 the random values will be evenly weighted.

    As the weight decreases the values will begin to be weighted toward the ‘max’ value. At a weight of 0 the expression will always return 10.

    As the weight increases above 1 the values will be weighted toward 0. At sufficiently high values (>100000) it will become very unlikely to return values other than 0 (while technically the weight would have to be infinite to assure 0 is always returned).

    What this is essentially doing is applying a gamma curve to the random() values. If you want a visualization of this you can apply the fractal noise effect to a layer, then apply a levels effect and adjust the gamma slider. Notice how the random brightness values are pushed toward the light and dark depending on which side of 1.0 gamma you slide to.

    Darby Edelen

  • Kevin Camp

    October 17, 2013 at 11:49 pm

    [Darby Edelen] “max * Math.pow(random(), weight)”

    much neater.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy