I'm a software developer not a statistician, so use small words. :)
I'm looking for an algorithm to generate a sequence of AB tests that are randomly distributed to users, but ensures an equal distribution. The sequence must be reproducible using a seed value.
(I'll get around to actually finding a software algorithm, but first I need to understand/clarify what I'm trying to do.)
So: 6 subjects or 50 or 500 (always an even number).
- Exactly half the subjects must get test A then test B, the other half must get B then A.
- The profile cannot be simply AAABBB, since the subject list is not necessarily randomized.
- It needs to be reproducible. So, a "seed" number will ensure I can get that exact same distribution again.
- The seed also ensures I can guarantee a different sequence if that's what I want.
My first shot at this involves a random profile where the second half is "flipped", ensuring it's symmetrical.
So: 20 subjects, Seed = 314
My simple algorithm just runs through the seed, toggling A to B until it hits the halfway point, then reverses the sequence:
3 1 4 3...
A A A B A A A A B B (flip) A A B B B B A B B B
B B B A B B B B A A B B A A A A B A A A
...3 4 1 3
One of the things I've run up against is that, for a small number such as 6, a seed number must be highly constrained, or several different seeds will result in the same profile.
So: 6 subjects, Seed = 523
5...
A A A (flip) B B B
B B B A A A
...5
but seed 427 does the same thing:
4...
A A A (flip) B B B
B B B A A A
...5
(In fact, there are so few possible permutations of profiles, the seed itself must be constrained to no more than about 24 or so possible values. Not really a seed anymore. More like 'pick a number from 1 to 24')