Calculate the number of changes

What do you want to do

** Book exhibition and sale event ** is planned. The price of the book is 3000 yen. The maximum number of purchasers is 50. How many 1000-yen and 5000-yen bills should I prepare to ensure that I don't run out of change?

If you never run out

Consider the following three patterns as possibilities.

method of payment Change
3 1000 yen bills None
5000 yen 1 sheet 1000 yen 2 sheets
10000 yen 1 sheet One 5000 yen and two 1000 yen

Since the pattern of 10,000 yen includes the number of all patterns, the worst case is when 50 people pay 10,000 yen, 1000 yen is 100 sheets, 5000 yen is 50 sheets, total 350,000 yen You will have to prepare a minute of change.

If you don't run out as much as possible

The probability that all 50 people will be 10,000 yen is extremely small. From Simulation of the contents of the wallet, the contents of the wallet are assumed to be the following probabilities, and the contents of each wallet are assumed to be independent.

Number of bills probability
0 1000 yen bills 20%
1 1000 yen bill 20%
Two 1000 yen bills 20%
3 1000 yen bills 20%
4 1000 yen bills 20%
5000 yen 0 sheets 50%
5000 yen 1 sheet 50%

From this, the probability of the payment pattern is: (If you have a bill, you will use it)

method of payment Change probability
3 1000 yen bills None 40%
5000 yen 1 sheet 1000 yen 2 sheets 30%
10000 yen 1 sheet One 5000 yen and two 1000 yen 30%

(Probability of 10,000 yen = 5000 yen 0 sheets x 1000 yen (0 to 2 sheets) = 0.5 x (0.2 + 0.2 + 0.2) = 0.3)

Since we assumed that each payment was independent, the sum of several or more people can be considered a normal distribution. Let's simulate and check.

python


r = []
for i in range(100000):
    n = 100
    p = np.random.rand(50)
    for x in p:
        if x < 0.3:
            n += 1
        elif x < 0.6:
            n -= 1
    r.append(n)
r = np.array(r)
plt.hist(r, bins=20, range=(50, 150))
print('%.3f %.3f' % (r.std(), math.sqrt(50 * 0.6)))
>>>
5.472 5.477

image

The distribution of the number of 1000-yen bills and the number of 5000-yen bills is as follows.

Distribution of the number of 1000 yen bills ~ $ N (n \ mu_ {1000}, n \ sigma ^ 2_ {1000}) $ \mu_{1000} = 0.4 ~ ~ 3 + 0.3 ~ (-2) + 0.3 ~ (-2) = 0 \sigma^2_{1000} = 0.4 (3-0)^2 + 0.3 (-2-0)^2 + 0.3 (-2-0)^2 = 6

Distribution of the number of 5000 yen bills ~ $ N (n \ mu_ {5000}, n \ sigma ^ 2_ {5000}) $ \mu_{5000} = 0.4 ~ ~ 0 + 0.3 ~ 1 + 0.3 ~ (-1) = 0 \sigma^2_{5000} = 0.4 (0-0)^2 + 0.3 (1-0)^2 + 0.3 (-1-0)^2 = 0.6

Assuming that the probability of not having enough change is 5%, it can be calculated using 1.67591 at (0.1, 50) on both sides t distribution table.

python


tv = 1.67591 
print('1000 yen%.3f' % (math.sqrt(50 * 6) * tv))
print('5000 Yen%.3f' % (math.sqrt(50 * 0.6) * tv))
>>>
1000 yen 29.028
5000 yen 9.179

In the end, you will have 30 pieces of 1000 yen and 10 pieces of 5000 yen, for a total of 80,000 yen. (Calculated based on whether or not it runs out at the end, not on the way) At this time, the probability that either one will be insufficient is about 10% ($ = 1- (1-0.05) ^ 2 $) when calculated simply, but in reality, it is thought as follows, so it is 5%. I can say.

Case probability meaning
1000 yen surplus 5000 yen surplus 0.9025 OK
1000 yen surplus 5000 yen shortage 0.0475 It's OK to return even the extra 1000 yen
1000 yen shortage 5000 yen surplus 0.0475 NG
1000 yen shortage 5000 yen shortage 0.0025 NG

that's all

Recommended Posts