Search code examples
javarandommaxaveragemin

Generate a random number with max, min and mean(average) in Java


I need to generate random numbers with following properties.

Min should be 200

Max should be 20000

Average(mean) is 500.

Optional: 75th percentile to be 5000

Definitely it is not uniform distribution, nor gaussian. I need to give some left skewness.


Solution

  • Java Random probably won't work because it only gives you normal(gaussian) distributions.

    What you're probably looking for is an f distribution (see below). You can probably use the distlib library here and choose the f distribution. You can use the random method to get your random number.

    enter image description here