# Random Expression The Random Function works on a variety number of parameters Values, which allows flexibility. It returns a different value on every frame.

#### random (maxValorArray);

For example, if you apply the code `random (80)`; on the opacity property. It would created a strobing light effect from zero to 80.

random (maxValorArray); This will always return a number in a given range from the value of the Argument to zero.

In the example below `random (50); ` is placed on the Opacity property and then the Rotation property. They are both have only one dimension, therefore only one argument is needed.

Other Properties that hold two dimension such as the Scale (width, height), Position/Anchor ( X, Y ) axis and others properties. The random expression will need to be put inside Variables.

#### Position Property

1. Make a Variable to hold the random function inside the position property.
• ` a = random (50); `
2. Then make Variables for X & Y. Type the Variable `X = `the Composition Width `thisComp.width` and find the center by dividing it by two `/2`. Then do the same with the Y Variable using the height attribute.
• `X = thisComp.width/2`
• `Y = thisComp.height/2`
3. Lastly call the array of the position property. Remember it has two dimension `[x, y] `
4. Apply the random function to one axis by adding `+ a ` to X or Y, since variable a holds the random function.
• `[ x, y + a]` Random function applies to the Y-axis only
• `[ x + a, y]` Random function applies to the X-axis only

#### Moving Randomly X-axis

Now if you want the Random function to work across the whole width. You don’t need a separate Variable for the Random function. Only for the X and Y. And by using the composition attribute calling `thisComp` and adding the `width` or `height` this can be placed inside of the Random argument.

`x = random (thisComp.width); `

`y = thisComp.height/2; ` // Dividing by 2, centers the vertical position

`[x, y] `

#### random (minValorArray, maxValorArray,);

random (minValorArray, maxValorArray ); This provides a custom range of values of Arguments with two values the minimum and maximum.

• Random on Opacity Property
• `random (50, 100);` The Arguments are 50 the min value and 100 max value
• In the example below you can see it randomly changes the opacity on every frame between those two values 50% to 100%
• Random on Scale Property for Equal Proportions
• This property has two dimensions, so to have the triangle equally moving in size the random function must be the same for two numbers in the array.
• `a = random (60, 150);`
• `[a, a] `
• Random on Scale Property for Unequal Proportions
• Now if you want the triangle to be stretch horizontally and vertically. Create two Variables and put them in the array.
• `a = random(30,100);`
• `b = random(20,80);`
• `[a, b]`
• Random on Source Text Property for a Random Number Counter
• You want to create a random number counter, but only whole numbers.
• On a Text Layer open the Source Text Property stop watch. Now create 2 Variables. 1) Random expression 2) Create whole numbers using the` math.round ()` function.
• `a = random (0, 150);`
• `b = Math.round(a) `

Control the Speed. Add from Effects & Presets “Posterize Time“. This allows you to control the Frame Rate and slower or increase the speed of the animation.

#### gaussRandom( )

gaussRandom( ); It returns numbers not at random values but in a bell-shaped curve, for its output values. Only 10% are outside the main range. It looks more natural than just using the random ( ) function. It also can have 1 Argument gaussRandom(maximum value or array); 2 Arguments gaussRandom (minimum value, maximum value);

The example below shows the difference when applied to the opacity property.