B
B
blantcat2017-06-07 13:07:53
PHP
blantcat, 2017-06-07 13:07:53

How to distribute gifts evenly?

Good afternoon.
There is a range of dates when the draw is valid, for example from 2017-05-05 to 2017-06-05. And there are n gifts, for example 10. They need to be played so that there are not 10 wins in 1 day, but there is a uniform distribution over the entire range of dates.
Please tell me the simplest solution to this problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2017-06-07
@blantcat

Specifications:
Solution: dynamically calculate the probability of winning, depending on the current date , the number of wins on that day and the balance: prizes and days until the end.
The probability, in the end, can be zero (if there are enough winnings on that day), 100% if the balance of prizes is large and there are not enough days, and somewhere between 0 and 100% in other cases. Make up your own formula.
For a probability $probfrom 0 to 100%, the win is determined something like this:

$win = rand(1, 100) <= $prob;
if( $win) { // вы выиграли! }

Truly random distribution does not exclude hits incl. and 10 draws for 1 day. But since your audience is not versed in probability theory, just use the random.org service N times:
  1. if N < числа днейselect N days from the range;
  2. these days, play for 1 prize - on the same change.org with a live video broadcast of the process.

L
Lander, 2017-06-07
@usdglander

Ummm... Cron every 3 days?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question