Noise Function not returning average of 0.5 over "time"

Hey everyone, I'm having a great time making "art" with lots of random walker objects, but observed when I created thousands of walkers with Perlin noise they had a tendency to go to the top left of the screen if they started in the middle - not so random!

I have done some investigating at it looks like the noise function does not average 0.5 over "time" (by trial and error I get it to be more like 0.47322). Can anyone advise if something I am doing is wrong?

Also how can I correct the random walkers tending in a single direction if using something like map(noise,0,1,-1,-1)?

To show it, the below code I use counts the number of times a random number is less than and greater than 0.5 - if you run it multiple times you will see "less than" ALWAYS wins. (and by quite a margin circa 20%)

The code for this I have is:

int less=0, more=0; float noisey; float i=0; int j=0; void setup() { while (i<1000) { noisey = noise(i); if (noisey<0.5) { //0.47322 looks to be closer to the expected value of noise() less++; } else { more++; } i=i+0.01; } println("less is "+less+" and more is "+more); println("if less wins, turn the threshold down!"); }

Graphically when I make LOTS of random walkers in the middle this is where they go if I use map(noise,0,1,-1,1);

RWA2017128162719

I look forward to your replies, thank you in advance.

Sign In or Register to comment.