mardi 16 novembre 2021

How to write a random multiplier selection function?

I am trying to write a function that the returns one of the following multipliers randomly selected but following the frequency requirement. What below table defines is that for 1 Million calls to this function the 1500 will be returned once, 500 twice and so on.

|---------------------|------------------------------|
|      Multiplier     |     Frequency Per Million    |
|---------------------|------------------------------|
|          1500       |         1                    |
|---------------------|------------------------------|
|          500        |         2                    |
|---------------------|------------------------------|
|          200        |         50                   |
|---------------------|------------------------------|
|          50         |         100                  |
|---------------------|------------------------------|
|          25         |         20,000               |
|---------------------|------------------------------|
|          5          |         75,000               |
|---------------------|------------------------------|
|          3          |         414,326              |
|---------------------|------------------------------|
|          2          |         490521               |
|---------------------|------------------------------|

Wondering what would be the best way to approach implementing this.




Aucun commentaire:

Enregistrer un commentaire