lundi 28 mars 2016

Create numbers with boundaries based on a probability per number

I would like to create some numbers each time based on a probability.

Example:

Numbers from : 1-5

Number 1 has probability to be created by 0.55,

Number 2 has probability to be craeted by 0.25,

Number 3 has probability to be craeted by 0.10,

Number 4 has probability to be craeted by 0.05,

Number 5 has probability to be craeted by 0.05

In this case, it has to usually create number 1, and often number 2, sometimes number 3 and rarely number 4 or 5

So, the "method": create_the_numbers(int ending_number) should be like this pseado-code:

public int create_the_numbers(int ending_number){
return probability(Random.getInt(ending_number))
}

There is an question for the C# here: Probability Random Number Generator




Aucun commentaire:

Enregistrer un commentaire