I need to create a script that prompts every 4th or 9th user as a sampling of users that visit over a day, but I dont have a way to store a global counter (file system, memory etc), is there an algorithm or function that could approximate selection of an nth user?
Or even a probability sampling would work… Say for 25%
Approximate, preferbably something with more speed than accuracy
An alternative could be a probabalistic sampling.
If you want to sample every K’th user (for some specific k), you need to generate a random integer in range
[0,K)– and sample this user if and only if the generated number is 0 (or any other single number actually).The expected number of sampled users will be the same as you sampled every kth user.