decorative banner

Random number methods


    Number random() The resulting value is a random number between 0 and 1.

    Number random(max) {max is a number} The resulting value is a number between 0 and max, and is the same dimension as max.

    Number random(min, max) {min and max are numbers} The resulting value is a number between min and max.

    Array random(max_arr) {max_arr is an array} The resulting value is an array with the same dimension as max_arr, with each component ranging between 0 and max_arr.

    Array random(min_arr, max_arr) {min_arr and max_arr are arrays} The resulting value is an array with the same dimension as min_arr and max_arr, with each component ranging between min_arr and max_arr. For example, the expression "random([100, 200], [300, 400])" returns an array whose first value is between 100 and 300, and whose second value is between 200 and 400. If the two input dimensions don't match, the shorter one is filled out with zeros.

    Number gauss_random() The resulting value is a random number between 0 and 1. The results have a bell-shaped distribution. About 90% of the results are between 0 and 1, and the remaining 10% are beyond the edges.

    Number gauss_random(max) {max is a number} The resulting value is a random number between 0 and max. The results have a bell-shaped distribution. About 90% of the results are in the 0 to max range, and the remaining 10% are beyond the edges.

    Number gauss_random(min, max) {min and max are numbers} The resulting value is a random number between min and max. The results have a bell-shaped distribution. About 90% of the results are in the min to max range, and the remaining 10% are beyond the edges.

    Array gauss_random(max_arr) {max_arr is an array} The resulting value is an array with the same dimension as max_arr, with 90% of the results ranging between 0 and max_arr and the remaining 10% beyond the edges. The results have a bell-shaped distribution.

    Array gauss_random(min_arr, max_arr) {min_arr and max_arr are numbers} The resulting value is an array with the same dimension as max_arr, with each component ranging between min_arr and max_arr. The results have a bell-shaped distribution. About 90% of the results are in the min_arr to max_arr range, and the remaining 10% are beyond the edges.

    Nothing seed_random(n) {n is a number} This expression takes the existing seed and increments it by the argument. Use it when you don't like the results you get from random or gauss_random. For example, "seed_random(3); random(10,20)".

    Number noise(val) {val is a number or an array [2 or 3]} This returns a number between 0 and 1. Noise is not actually random, but is used when you want a seemingly random number with some correlation between nearby samples. It is based on Perlin Noise (see a computer graphics reference book for more information). For example, "add(position, [noise(position)*50])".