-5

I'm looking for a way to generate a random number with:

  • A lower and upper boundary
  • An average not in the middle of the specified range
  • An adjustable standard deviation

In Java.

More specifically: I want to generate a long list of numbers with a minimum of 0, maximum of 40 and an average of +- 5, and i'd like to be able to adjust how far around the average the numbers are.

1 Answers1

1

Sadly statistics doesn't work like that.

  1. You need to define the distribution that you want.

  2. You then get the quantile function for that distribution.

  3. You then draw a uniform number in [0, 1).

  4. You apply the quantile function to (3).

The distribution of (4) will then have the properties that you want.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483