Problem statement: Reward a customer with lucky draw coupon of X% discount in between 1% to 100%
Assume that slabs are pre-defined ( all are theoretical)
1% discount : 90% customers
10% discount : 5% customers
20% discount : 3% customers
100% discount : 2% customers
Solution 1: (Uniform distribution, nextInt() in java)
For every 100 customers, I will pre-populate a random array of size 100 with a good shuffling algorithm
90 1s ( 1 = 1% discount)
5 10s ( 10 = 10% discount)
3 20s ( 20% discount )
2 100s ( 100% discount)
Whenever a customer comes, I will draw random.nextInt() and get discount percentage in array
Solution 2: (Normal distribution - nextGaussian in java)
Use nextGaussian() of SecureRandom which allows distribution in bell-curve.
Refer to example 1 & 3 in Random
Which one is preferred? - Uniform distribution Vs Normal distribution
Thanks in advance.
I can't see why you would use a normal distribution, which is a bell-shaped curve—not what you want. Use a uniformly-distributed random variable.
Solution $1$ is acceptable only if you don't care that there is quite a bit of dependence between customer rewards (since it seems you basically assign $90$ one-percent coupons, $5$ ten-percent coupons, $3$ twenty-percent coupons, and $2$ free coupons in cycles of $100$ customers). This ensures that every $100$ customers, the counts are precisely as expected, but it removes luck entirely from the equation.