Skip to content

Drive-Thru Daiquiris Problem


You own a chain of drive-thru daiquiris 🥤. (Yes, they exist.) Build a plot like the one below showing the distribution of sales per store, per hour.

import numpy as np

rng = np.random.default_rng(1234)

p1 = [0.05, 0.03, 0.02, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0.03, 0.04,
      0.07, 0.07, 0.08, 0.08, 0.08, 0.12, 0.15, 0.18, 0.15, 0.12, 0.08, 0.06]
p2 = np.concatenate((p1[-5:], p1[:-5]))
p3 = np.concatenate((p1[5:], p1[:5]))

# sales per store
s1 = rng.choice(24, size=1000, replace=True, p=p1/np.sum(p1))
s2 = rng.choice(24, size=2000, replace=True, p=p2/np.sum(p2))
s3 = rng.choice(24, size=1750, replace=True, p=p3/np.sum(p3))

print(s1[:5]) # [23 16 22 13 14] (1)
print(s2[:5]) # [22 17 11 22  0]
print(s3[:5]) # [16  7 12 15 17]
  1. Each element in s1 represents the hour in which a daiquiri sale occurred. The first five sales of s1 occurred during hours 23, 16, 22, 13, and 14.
Show the plot


Try with Google Colab