Answer the question
In order to leave comments, you need to log in
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
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 $prob
from 0 to 100%, the win is determined something like this:
$win = rand(1, 100) <= $prob;
if( $win) { // вы выиграли! }
N < числа дней
select N days from the range;Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question