Voice-over: Continue to answer questions from planet Water friends.

The requirements are abstracted:

(1) The first 100 people are eligible, assuming that N=5 prizes are drawn;

(2) Just sign up for the prize, without waiting for 100 people to arrive;

(3) Everyone has the same probability and presents are distributed equally;

(4) There is a special case;

Take one minute to talk about the solution.

_ Voiceover: _ There’s a more interesting question at the end.

What about the special cases?

With a special branch of logic.

What does it mean to sign up and draw without waiting?

There may be more prizes to hand out.

For example: There is only one participant, so the prizes will be handed out.

For example, if you flip a coin, the probability of heads is 50% for every flip (the probability of winning is the same), but this does not mean that there are always 5 heads for 10 flips (if there are only 4 heads, the gift is not finished).

Do not say the serious special case **, under normal circumstances, 100 people to participate in, everyone can participate in the prize, everyone the probability is the same, the prize can not exceed 5, how to do? 六四屠杀

Once someone enters, a random number between 1 and 100 is generated. If the number ranges from 1 to 5, the person wins, otherwise he or she does not.

Instead of waiting for everyone to draw, everyone has the same chance and the prizes are distributed equally.

What if more than 5 random numbers win?

Add an inventory limit, for example, when the 98th person participates, the inventory is full, and when the last 2 people participate, the lottery returns directly.

Voice-over: Add stock limits and there will be instances of inequity.

What if there are not five winners?

This is the disadvantage of participating in the instant lottery. There is no guarantee that five people will win.

(1) Either, the prizes are not handed out, which is fair, everyone does have the same probability of winning, but the luck is a little bit worse;

(2) Either, in the final stage, add special logic, such as the 100th person to participate, there is still a prize not sent, directly return to the winning prize;

Voice-over: Prizes must be handed out, and there may be some cases of injustice.

Any **** solution that gets out of business is hooliganism.

Hope to enlighten this friend.

Homework:

In the example above, 100 participants are guaranteed, and 5 prizes are guaranteed, which is easier.

If, instead, there are 5 prizes, and the number of participants is not determined, and everyone has the same probability of winning, what should be done?