# Optimising files for a random playback algorithm - any statisticians or programers here?

1. I'm trying to work out the best way to organise music on the Tera Player.

I know how it works - it chooses a random number between 0 and 128 and if it finds an item it uses it, if not it does a binary shift, repeat as required.  This is done three times to choose an "artist" then an "album" and finally a track.

The problem this algorithm is that whatever it puts last in the list gets massively overplayed compared to what's first - I've made a spreadsheet to simulate this.

To achieve randomness what you need to do is pad the folders/files to put all the real music at the same binary level (3-4, 5-8, 17-32 etc) - easy enough.

However there is a problem if you don't have exactly 2, 4, 8 etc items because when it plays random it is much more likely to hit a "blank" which creates a gap between the tracks, which is what I'm trying to avoid.

I've come to a point where I need to understand probability better to work out whether it's best to put (e.g) 28 albums in

2 folders of 14
4 folders of 7
4 folders of 3 and 4 of 4
or just leave them loose..

but I can't get my head around it!

If you've got this far congratulations, please post anything you think could help, or if you're interested enough to want to have a go feel free to ask questions as I'm not known for being great at explaining things.