Random walk and random distribution visualisation
This commit is contained in:
19
random_visualisation/randpm_visualisation.pde
Normal file
19
random_visualisation/randpm_visualisation.pde
Normal file
@ -0,0 +1,19 @@
|
||||
int[] randomCounts;
|
||||
|
||||
void setup() {
|
||||
size(640, 240);
|
||||
randomCounts = new int[20];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
int index = int(random(randomCounts.length));
|
||||
randomCounts[index]++;
|
||||
stroke(0);
|
||||
fill(175);
|
||||
int w = width/randomCounts.length;
|
||||
|
||||
for(int x = 0; x < randomCounts.length; x++) {
|
||||
rect(x * w, height - randomCounts[x], w - 1, randomCounts[x]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user