pub static randomGaussian: RandomGaussianInternalTypeExpand description
Returns a random number fitting a Gaussian, or
normal, distribution. There is theoretically no minimum or maximum
value that randomGaussian() might return. Rather, there is
just a very low probability that values far from the mean will be
returned; and a higher probability that numbers near the mean will
be returned.
Takes either 0, 1 or 2 arguments.
If no args, returns a mean of 0 and standard deviation of 1.
If one arg, that arg is the mean (standard deviation is 1).
If two args, first is mean, second is standard deviation.
Examples
for (let y = 0; y < 100; y++) {
let x = randomGaussian(50, 15);
line(50, y, x, y);
} let distribution = new Array(360);
function setup() {
createCanvas(100, 100);
for (let i = 0; i < distribution.length; i++) {
distribution[i] = floor(randomGaussian(0, 15));
}
}
function draw() {
background(204);
translate(width / 2, width / 2);
for (let i = 0; i < distribution.length; i++) {
rotate(TWO_PI / distribution.length);
stroke(0);
let dist = abs(distribution[i]);
line(0, 0, dist, 0);
}
}Parameters
mean? the mean
sd? the standard deviation