The distribution of [..., ..., ...].rand

Dear users,

Is the random distribution of No. 1 as expected in the following plot? I think No.1 should be distributed similarly to No. 2 rather than No. 3. :thinking:

I am not sure about it even though having read the following post:

(
[
	(1..100).rand.sort,            // No. 1.
	({ rrand(1, 100) }!100).sort,  // No. 2.
	({ exprand(1, 100) }!100).sort // No. 3.
]
.plot
.superpose_(true)
.plotColor_([
	Color.green, // No. 1.
	Color.cyan,  // No. 2.
	Color.blue   // No. 3.
])
)

compare these:

(
[
	{ 100.rand }.dup(100).sort,            // No. 1.
	(1..100).rand.sort
]
.plot
.superpose_(true)
.plotColor_([
	Color.green, // No. 1.
	Color.cyan,  // No. 2.
])
)

(1…100).rand is: [ 1.rand, 2.rand, 3.rand … 100.rand ] … so yes that’s as expected !

(in the resulting array you can have at most 1 100, 2 99’s, 3 98’s … 100 0’s)

1 Like

Thank you very much!
(1..100).rand.sort was falsely thought.
It should be ({ 100.rand }!100).sort