Sha256: 15c2292fd58fccd7ff52169213ba850a030f0fdb5590feb4f1716dda2585388f

Contents?: true

Size: 644 Bytes

Versions: 10

Compression:

Stored size: 644 Bytes

Contents

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

def setup
  size(640, 360)
  background(0)
end

def draw
  # Get a gaussian random number w/ mean of 0 and standard deviation of 1.0
  val = random_gaussian
  sd = 60                  # Define a standard deviation
  mean = width/2           # Define a mean value (middle of the screen along the x-axis)
  x = (val * sd) + mean    # Scale the gaussian random number by standard deviation and mean
  fill(200, 20)
  no_stroke
  ellipse(x, height/2, 32, 32)   # Draw an ellipse at our "normal" random location
end


Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.6.2 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.6.1 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.6.0 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.5.1 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.5.0 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.4.4 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.4.3 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.4.2 samples/processing_app/basics/math/random_gaussian.rb
ruby-processing-2.4.1 samples/processing_app/basics/math/random_gaussian.rb