.rand not generating evenly distributed numbers?


#1

Hello synths,

I am running the following code:

Array.fill(9999999, { 1.0.rand }).plot;

But when plotting, it seems that when it goes to the extremes ( 0.9< x <1.0 and 0.0< x <0.1) the density probability is lower.

Am I doing something wrong here or is this a bug?

[ ]'s


#2

Don’t trust the optical impression of plot in extreme cases. As with audio waveforms it can be pretty wrong. It’s easy though to check analytically:

n = 9999999;
x = Array.fill(n, { 1.0.rand });
y = x.histo(10, 0, 1);