jeudi 11 juin 2020

random number generator with probability in C

I have a variable in the range of 0 to 1. this variable shows the probability of a decision and 1 has the highest probability for a decision and 0 has the least.

I want to make a comparison between this variable and a random number in a way that I can delete some of the entries in the probability function but I want to delete the probabilities with has a lower value.

If we consider P as the list of probabilities:

 P={0.05,0.06,0.08,0.5,0.8,0.9,0.95}

 for x in P:

       if x> randomValue:

             The decision will be applied
       else:
             Removing x from P

I don't know how should define the random value to be sure it tends to remove low probability entries more than high probability entries.




Aucun commentaire:

Enregistrer un commentaire