
import math
import numpy as np
import statLib as sl
# Raw data
data = [8, 5, 9, 15, 6]
# Model parameters:
maxCap = 10 # maximum number of customers that can be handled on a day
mu = sl.average(data)
lmbda = mu
sigma = sl.sd(data)
c_P = 1000 # Penalty cost per customer
c_U = 500  #Investmet cost for upgrade
print("Estimate of mu =",mu)
print("Estimate of sigma (SD) =",sigma)
print("Estimate of SD if Poisson = ", math.sqrt(lmbda))

c_I = 0
for i in range(2): # We loop twice, first with initial capacity, then we increase maxCap with 3
    print("\nResult for max capacity =",maxCap)
    # Normal distribution
    n_LC = sl.B(maxCap+0.5,mu,sigma)
    print("Normal: Total cost = ",c_I + n_LC * c_P)
    # Poisson distribution
    n_LC = 0
    for x in range(maxCap+1, maxCap+20): # MaxCap + 20 = approx infty
        n_LC += (x-maxCap)*sl.pdfPoisson(x,lmbda)
    print("Poisson: Total cost = ",c_I + n_LC * c_P)
    c_I += c_U
    maxCap +=3

print("\nNote that since SD is lower if we assume Poisson, the cost is also less, i.e., low prob. of many customers one day")
