[mythtv] MythMusic playlists still not intelligent enough IMHO
Eskil Heyn Olsen
myth at eskil.org
Thu Apr 19 05:45:02 UTC 2007
On Wed, 2007-04-18 at 10:50 -0400, Dan Wilga wrote:
> - choose the index of the first song, S, randomly: S = rand() % N
> - afterward, each new song, S' is calculated like so: S' = (S + P) % N
> A mathematics guru friend of mine sent me the proof that this
> sequence is guaranteed to visit each song exactly once, in a
> pseudorandom order. It also has the advantage that the sequence is
After looking at this, it seems that the pseudorandom order is just
continuously adding P % N to S and wrapping at N. So essentially, let N
be 50, P be 15485863 (big prime) and S0 be 20.
S1 = (20 + 15485863) % 50 = 33
S2 = (33 + 15485863) % 50 = 46
S3 = (46 + 15485863) % 50 = 9
S4 = (9 + 15485863) % 50 = 22
essentially you just add 13 (15485863 % 50) every time. That seems sub
pseudorandom to me. It even seems that the only reason you need a prime
is to ensure that P % N isn't 0.
Or did I (again) brainfart on something ?
More information about the mythtv-dev