I'm trying to write a function that'll take a set of results, assign a probability to each result, and then pick one result at random, according to its probability.

Soooo... I thought I'd calculate the area under sections of a basic parabolic function (y = x^2) to generate the skewed probabilities.

Because of the nature of this curve, the amount of skew is determined by the range of the parabola used, as x tends to zero, the gradient tends to zero, so using 0 - 0.001 would be only slightly skewed. As x tends to infinity, the gradient tends to inifinity, so using values 0 - 100 the probabilities would be heavily skewed.

to recap then, my function would be passed a skew factor, essentially the upper limit of the parabolic graph to use. All I need do is divide the whole range into equal sections according to the number of values and determine the definite integral for each range of the parabola assigned to each of the possible values. Make sense? Good.

integrating y = x^2 gave me y = x^3 / 3

from this I developed the following code:
PHP Code:
vals = ["dog""cat""monkey""horse""marmotte""hampster""yetti""ant""mouse""duck"];
skewfactor 9;

getProbabilities(vals: Array, skewfactorNumber): Array {
totNumber Math.pow(skewfactor3) / 3;
rangeNumber skewfactor vals.length;
probs: Array = new Array();
lastboundNumber 0;
countNumber 0;
count vals.length) {
uboundNumber = (count 1) * range;
probs[count] = ((Math.pow(ubound3) / 3) - (Math.pow(lastbound3) / 3)) / tot;
lastbound ubound;

and it kinda worked. It produced a set of probabilities which looked like they fell in line with a simple parabola.

My problem is that no matter what skew value (i.e. max range) I pass in, it produces exactly the same results and I'm not sure if my maths is wrong, my theory on the nature of the curve is wrong or if my code is wrong.

Any thoughts, comments or pointers welcomed