jeudi 10 juin 2021

Generate random number given a probabilty the higher the probability is the higher the result

I am working on a simple project and I have this method:

public int generatePeople(float luck, int min, int max) {
    SecureRandom sr = new SecureRandom();
    int people = 0;
    // generate random people
    return people;
}

I would like to generate an amount of people between min and max, but the number of people increases or decreases depending on the variable luck, this should be similar to a Gaussian but I have no idea on how to do it on Java.




Aucun commentaire:

Enregistrer un commentaire