going off loriel's post... I came up with:
PHP Code:
function onCreated() {
temp.tmax = 10;
temp.rand = function (m) { return int(((1-random(0,1)^0.5)) * m) };
for (temp.i = 0; temp.i < 1000; temp.i++) {
temp.("count_" @ temp.rand(temp.tmax))++;
}
for (temp.i = 0; temp.i < temp.tmax; temp.i++) {
echo(temp.i SPC temp.("count_" @ temp.i));
}
}
/*
Sample:
0 179
1 170
2 145
3 126
4 115
5 95
6 75
7 59
8 27
9 9
*/
one other way I tried:
PHP Code:
function onCreated() {
temp.tmax = 10;
temp.rand = function (m) {
temp.i = 0;
while (random(0,1) > 0.5 && temp.i < m) {
temp.i++;
}
return temp.i;
};
for (temp.i = 0; temp.i < 1000; temp.i++) {
temp.("count_" @ temp.rand(temp.tmax))++;
}
for (temp.i = 0; temp.i < temp.tmax; temp.i++) {
echo(temp.i SPC temp.("count_" @ temp.i));
}
}
/*
Sample:
0 520
1 243
2 132
3 56
4 27
5 12
6 2
7 3
8 3
9 1
*/
I'm sure there's a math way to do it but **** it.