I have a list of sounds that are to be played when the user presses a button.
For now I just generate a random number within the range of the list and just pick the sound with that index. (I also prevent that sound from being played the next time the button is clicked. Since that is easy, I would like to concentrate only on the selection algorithm and leave the exclusion behind.)
Since that makes it possible for a few sounds to be played repeatedly in a pattern, I would like to adjust my algorithm:
Once a file is played it gets moved to the end of the list. Sounds from the beginning have a greater chance of being played than those at the end - therefore minimizing repetition.
Instead of assigning a weight to each index, I want to have one factor determining the probability falloff. For example, I would set this factor to be 1.2 which means that each index is 1.2 times as probable to be played as the following one. This hopefully produces a nice falloff in probability.
The fastest solution seems to be a mathematical function that maps the random number to the range of indices. That way I do not have to set up intervals, but can directly calculate the result based on the random number.
I just cannot figure out the math and implementiation behind this idea, so I need you to lay it out for me. The algorithm will be used in an Android app, so the programming language I am using is Java.