I'm searching for a method or library for java (can be java-8) that is capable of generating a random sample (preferable with a fixed seed for deterministic testing) based on the numbers that make up a boxplot.

So imagine having the boxplot:

```
----------
|-----| | |-----------|
----------
min A avg B max
```

where you now the numbers `min`

, `A`

, `avg`

, `B`

, and `max`

. The method or library should generate a random number that is bound with these rules.

# Best How To :

Supposed that `min`

, `a`

, `median`

, `b`

, `max`

values separate quartiles of distribution (http://en.wikipedia.org/wiki/Quartile):

```
static public double next(Random rnd, double median, double a, double b, double min, double max) {
double d = -3;
while (d > 2.698 || d < -2.698) {
d = rnd.nextGaussian();
}
if (Math.abs(d) < 0.6745) {
if (d < 0) {
return median - (median - a) / 0.6745 * (-d); // 2nd quartile
} else {
return median + (b - median) / 0.6745 * d; // 3rd quartile
}
} else {
if (d < 0) {
return a - (a - min) / (2.698 - 0.6745) * ((-d) - 0.6745); // 1st quartile
} else {
return b + (max - b) / (2.698 - 0.6745) * (d - 0.6745); // 4th quartile
}
}
}
```

Here, I discover in which quartile `d = rnd.nextGaussian()`

gets into, and project the value to corresponding part of the given boxplot.