Random Gaussian.

Random Gaussian.

This sketch draws ellipses with x and y locations tied to a gaussian distribution of random numbers.

void setup() {
  size(640, 360);

void draw() {

  // Get a gaussian random number w/ mean of 0 and standard deviation of 1.0
  float val = randomGaussian();

  float sd = 60;                  // Define a standard deviation
  float mean = width/2;           // Define a mean value (middle of the screen along the x-axis)
  float x = ( val * sd ) + mean;  // Scale the gaussian random number by standard deviation and mean

  fill(255, 10);
  ellipse(x, height/2, 32, 32);   // Draw an ellipse at our "normal" random location

Functions Used


Sets the color used to fill shapes

Learn More

Returns a float from a random series of numbers having a mean of 0 and standard deviation of 1

Learn More

Defines the dimension of the display window width and height in units of pixels

Learn More

Draws an ellipse (oval) to the screen

Learn More

The setup() function is run once, when the program starts

Learn More

Called directly after setup(), the draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called

Learn More

Disables drawing the stroke (outline)

Learn More

The background() function sets the color used for the background of the Processing window

Learn More