evanmcd
evanmcd

Reputation: 1969

What is the correct way to write a sweepstakes algorithm?

For example, if I wanted to ensure that I had one winner every four hours, and I expected to have 125 plays per hour, what is the best way to provide for the highest chance of having a winner and the lowest chance of having no winners at the end of the four hour period?

The gameplay is like a slot-machine, not a daily number. i.e. the entrant enters the game and gets notified right away if they have won or lost.

Sounds like a homework problem, I know, but it's not :)

Thanks.

Upvotes: 1

Views: 1171

Answers (2)

Jimmy Sawczuk
Jimmy Sawczuk

Reputation: 13614

There's really only so much you can do to keep things fair (i.e. someone who enters at the beginning of a four hour period has the same odds of winning as someone who enters at the end) if you want to enforce this constraint. In general, the best you can do while remaining legal is to take a guess at how many entrants you're going to have and set the probability accordingly (and if there's no winner at the end of a given period, give it to a random entrant from that period).

Here's what I'd do to adjust your sweepstakes probability as you go (setting aside the legal ramifications of doing so):

  • For each period, start the probability at 1 / (number of expected entries * 2)
  • At any time, if you get a winner, the probability goes to 0 for the rest of that period.
  • Every thirty minutes, if you're still without a winner, set the probability at 1 / ((number of expected entries * (1 - percentage of period complete)) * 2). So here, the percentage of period complete is the number of hours elapsed in that current period / number of total hours in the period (4). Basically as you go, the probability will scale upwards.

Practical example: expected entries is 200.

  • Starting probability = 1 / 400 = 0.0025.
  • After first half hour, we don't have a winner, so we reevaluate probability: probability = 1 / ((200 * (1 - 0.125) * 2) = 1 / (200 * 2 * 0.875) = 1/350
  • This goes down all the way until the probability is a maximum of 1/50, assuming no winner occurs before then.

You can adjust these parameters if you want to maximize the acceleration or whatever. But I'd be remiss if I didn't emphasize that I don't believe running a sweepstakes like this is legal. I've done a few sweepstakes for my company and am somewhat familiar with the various laws and regulations, and the general rule of thumb, as I understand it, is that no one entrant should have an advantage over any other entrant that the other entrant doesn't know about. I'm no expert, but consult with your lawyer before running a sweepstakes like this. That said, the solution above will help you maximize your odds of giving away a prize.

Upvotes: 2

Jim Rubenstein
Jim Rubenstein

Reputation: 6930

If you're wanting a winner for every drawing, you'd simply pick a random winner from your entrants.

If you're doing it like a lottery, where you don't have to have a winner for every drawing, the odds are as high or low as you care to make them based on your selection scheme. For instance, if you have 125 entries per hour, and you're picking every four hours, that's 500 entries per contest. If you generate a random number between 1 and 1000, there's a 50% chance that someone will win, 1 and 750 is a 75% chance that someone will win, and so forth. Then you just pick the entry that corresponds to the random number generated.

There's a million different ways to implement selecting a winner, in the end you just need to pick one and use it consistently.

Upvotes: 1

Related Questions