On 19 Sep 2005 08:56:11 -0700,

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote or quoted :

>Any clever ideas or hints would be much appreciated!
you need a course in elementary probability and statistics.

Here are some hints.

See

http://mindprod.com/jgloss/randomnumbers.htmls
here is how nextGaussian works to produce a normal bell shaped curve

distribution:

synchronized public double nextGaussian() {

if (haveNextNextGaussian) {

haveNextNextGaussian = false;

return nextNextGaussian;

} else {

double v1, v2, s;

do {

v1 = 2 * nextDouble() - 1; // between -1.0 and

1.0

v2 = 2 * nextDouble() - 1; // between -1.0 and

1.0

s = v1 * v1 + v2 * v2;

} while (s >= 1 || s == 0);

double multiplier = Math.sqrt(-2 * Math.log(s)/s);

nextNextGaussian = v2 * multiplier;

haveNextNextGaussian = true;

return v1 * multiplier;

}

}

It works by taking two random doubles.

Another common distribution is called Poisson.

You need to be more precise about just how the elements are skewed

more toward the high end before you can come up with a formula to skew

them.

Here is the general idea of how you can do this.

1. scale your random number 0..1 over a more interesting domain of a

function with a simple multiplication.

2. crank it through some non-linear formula, e.g. x squared, sqrt,

exp, log, log base n, x^n, a polynomial, a chebychev polynomial,

parabola,... doing this to exp(x) for example will result in points

being dense at the low end and sparse at the high end.

3. scale it back into suitable range with a multiplication.

Different formulae will give you different skewings. If you don't

have a particular mathematical model you need, just pick a formula

that satisfies you intuitively. Graph the function and the

distribution.

--

Canadian Mind Products, Roedy Green.

http://mindprod.com Again taking new Java programming contracts.