I need to generate random data for a geocaching game. I've a list of QuestMeasurement with QuestId, StageId and measurement value.
How can I generate random numbers that should have a different average per quest. (Right now all the averages are around the median of the boundries.)
Here's the code:
public static int getValueForMeasurementType(String measurementType) {
Random random = new Random();
return switch (measurementType) {
case HARTSLAG -> (int) (random.nextDouble() * (125 - 60 + 1) + 60) ;
case ZWEETNIVEAU -> (int) (random.nextDouble() * 101);
case GELUID -> (int) (random.nextDouble() * (100 - 30 + 1) + 30);
default -> 0;
};
}
When I calculate the average per QuestId:
Average HARTSLAG for quest 06541BCC50F2451EA5088464E6A6CD9C: 89.41176470588235
Average HARTSLAG for quest 08BC162BBC5A456A8BE9E24E76EEBF79: 95.11764705882354
Average HARTSLAG for quest 082DC01CC9D74CF0AEA7C79EAF616EEE: 89.79411764705883
Average HARTSLAG for quest 096AE1335FD648018A95968AFC8FBB12: 91.3529411764706
Average HARTSLAG for quest 0A5C24368F084608B0506ABB61138218: 92.38235294117646
Average HARTSLAG for quest 0A2934DD6996453E84826F7A703BCBC1: 90.13725490196079
Average HARTSLAG for quest 0870A3CAD0754C3DAFA686D202024A36: 90.02941176470588
Average HARTSLAG for quest 05555A33124D4298820C6E40DDF94B4D: 88.8970588235294
As you can see they all seem to be around the average.
Is there a way to manipulate the randomness so that per quest it should generate random numbers in a random range within the provided range?
Aucun commentaire:
Enregistrer un commentaire