say i generated a set of random numbers and put them into an array, (pre-sorted for simplicity) i'll use javascript to show the math:
var vals = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,...,10000);
then in a loop, i created a random number to serve as an index:
for(i=0;i<10000;i++){
var random_index = Math.floor(Math.random() * 10000);
var result = vals[random_index];
}
if you looked at this output on any kind of graph, the results (with enough iterations through that loop, will look pretty random and balanced)
what I want, is for the results of each access to favor smaller numbers, which incidentally here is array elements with a lower index.
for a visual example, imagine you're trying to plot on a map where the fragments of a firework fell. most of those fragments would fall randomly within a vicinity but have a heavier concentration towards the middle. that's a bit of an over-complicated example since it's taking another dimension into account and uses physics to achieve the result, but it's the same principal.
what operation should i perform on the random_index variable to make it 'favor' smaller numbers?
There are any number of things you can do.
For instance:
Math.floor(Math.sqrt(Math.random() * 10000^2));
The real question is, what kind of distribution do you want?