When Bad Random Functions Go Good?

Most software developers who have even a cursory knowledge of code security know that using the built-in rand() function for anything cryptographic is a bad idea.

Now take the issue of randomness in car CD players, for example. In the last year I replaced my car’s stolen stereo system with a new one. It’s a Kenwood and I’m generally happy with it, but it has got to have the WORST shuffle play I have ever seen…er… heard. Let me explain:

I created a WMA CD with about 80 favorite songs in the root directory. I have this CD in more often than not. Yesterday, as I was driving home it played the exact same set of songs as on the previous day driving home! They were in a different order, however. It was probably a subset of about 20 songs. What are the odds of that?

A second oddity I’ve noticed is that it more often than not plays two Elton John songs in a row (songs are ordered in alpanumerical order and most consist of something like “01 – My Song.wma”, where the number is the track number from the original album). I have maybe 5 on the CD.

But the really weird thing is that every time Trace Adkins’ beautiful tribute Arlington comes on I happen to be passing Arlington Cemetery right at that moment. This has happened each of the 4 times I’ve heard the song in my car. Each instance has been separated by at least a few weeks.

I would be interested in seeing the algorithm they use.


Check out my latest book, the essential, in-depth guide to performance for all .NET developers:

Writing High-Performance.NET Code, 2nd Edition by Ben Watson. Available for pre-order:

1 thought on “When Bad Random Functions Go Good?

  1. Pingback: Philosophical Geek » Bad Random Functions Redux

Leave a Reply

Your email address will not be published. Required fields are marked *