I would use the simio expression 2+Random.Exponential(9.92)
I would use the simio expression 2.76+Random.Lognormal(1.84,0.717)
I would use the simio expression 16+Random.Binomial(.015)
\(R = (X-a)/(b-a)\) =>
\(R(b-a) = (X-a)\) =>
\(R(b-a)+a = X\)
\(1-R=e^{-(x/\lambda )^k}\) =>
\(ln(1-R) =-(x/\lambda )^k\) =>
\(\lambda(-ln(1-R)) = X^k\) =>
\(x =\lambda(-ln(1-R))^{1/k}\)
So this question left out some needed information. I decided to uniformily distribute amount of customers, according to the max amount of customers walther could handle per grocery. Since Walther will always meet demand, but never go over a certain threshhold; I just assumed he would close up shop if the next purchase’s max would go over his leftover stock for the day.
#demand 10,8,14,11
#profit = .24,.59,.24,.7
oatsDist = c(0,.5,1,1.5,2,3,4,5,7.5,10)
oatsProb = c(.05,.07,.09,.11,.15,.25,.10,.09,.06,.03)
peasDist = c(0,.5,1,1.5,2,3)
peasProb = c(.1,.2,.2,.3,.1,.1)
beansDist = c(0,1,3,4.5)
beansProb = c(.2,.4,.3,.1)
barleyDist = c(0,.5,1,3.5)
barleyProb = c(.2,.4,.3,.1)
walthersShop = function(x,foodDist,demand){
theMax = floor(demand/foodDist[2]) #max amount of customers Walther has accounted for
amtCust = floor(runif(1,min=0,max=theMax+1)) #Lets give em a uniform dist
return(amtCust)
}
theDaily = function(x,foodDist,foodProb,demand){
total = 0
for(cust in 1:x){
newPurchase = sample(x=foodDist,1,prob = foodProb)
total = total + newPurchase
if((total+foodDist[length(foodDist)])>demand){
break
}
}
return(total)
}
oats = sapply(vector(length = 90),walthersShop,oatsDist,10)
oats = sapply(oats,theDaily,oatsDist,oatsProb,10)
peas = sapply(vector(length = 90),walthersShop,peasDist,8)
peas = sapply(peas,theDaily,peasDist,peasProb,8)
beans = sapply(vector(length = 90),walthersShop,beansDist,14)
beans = sapply(beans,theDaily,beansDist,beansProb,14)
barley = sapply(vector(length = 90),walthersShop,barleyDist,11)
barley = sapply(barley,theDaily,barleyDist,barleyProb,11)
cbind(oats,peas,beans,barley)
## oats peas beans barley
## [1,] 3.0 6.5 10.0 7.0
## [2,] 7.5 7.0 1.0 8.0
## [3,] 5.0 5.5 10.0 2.0
## [4,] 1.0 3.5 8.0 6.0
## [5,] 1.0 6.5 12.5 4.0
## [6,] 2.0 6.5 2.0 8.0
## [7,] 4.0 5.0 12.0 8.5
## [8,] 1.5 5.5 11.5 7.0
## [9,] 4.0 4.5 0.0 7.0
## [10,] 3.0 5.0 12.5 6.5
## [11,] 1.5 6.0 8.0 2.0
## [12,] 3.0 5.5 5.0 8.0
## [13,] 7.5 5.5 10.0 3.5
## [14,] 1.0 6.5 10.0 8.0
## [15,] 2.0 5.5 11.5 5.5
## [16,] 3.0 2.0 11.0 8.0
## [17,] 0.5 5.5 4.0 10.5
## [18,] 3.0 0.5 9.0 8.5
## [19,] 5.0 1.5 12.5 6.5
## [20,] 5.0 8.0 12.0 1.0
## [21,] 1.5 6.0 13.0 1.5
## [22,] 2.0 6.5 10.0 1.0
## [23,] 2.0 6.0 3.0 8.0
## [24,] 1.0 6.5 8.5 8.0
## [25,] 3.0 5.5 10.5 8.5
## [26,] 1.5 5.5 12.5 0.5
## [27,] 3.0 3.5 10.5 3.5
## [28,] 2.0 5.5 10.5 5.5
## [29,] 1.5 7.5 3.0 1.5
## [30,] 2.0 6.5 9.0 8.5
## [31,] 5.0 3.0 5.5 11.0
## [32,] 3.0 5.5 10.5 8.0
## [33,] 1.5 8.0 10.0 11.0
## [34,] 3.0 6.0 9.0 6.0
## [35,] 3.0 5.5 5.5 3.0
## [36,] 3.0 5.5 5.5 8.0
## [37,] 2.0 6.5 11.0 10.5
## [38,] 3.0 5.5 10.0 8.0
## [39,] 4.0 6.5 10.5 5.5
## [40,] 1.0 3.0 1.0 8.5
## [41,] 2.0 6.0 11.5 9.5
## [42,] 2.0 5.5 12.5 10.5
## [43,] 3.0 6.0 9.0 10.0
## [44,] 3.0 5.5 10.0 5.5
## [45,] 7.5 6.5 3.0 3.0
## [46,] 1.5 6.0 10.5 8.0
## [47,] 1.5 0.0 11.0 5.5
## [48,] 4.0 3.0 10.5 8.0
## [49,] 0.5 5.5 3.0 6.5
## [50,] 0.5 3.5 10.0 7.0
## [51,] 1.0 3.5 11.0 3.0
## [52,] 3.0 7.0 11.0 1.0
## [53,] 3.0 5.0 9.5 8.0
## [54,] 1.0 2.0 1.0 7.5
## [55,] 4.0 6.5 8.0 8.0
## [56,] 10.0 6.0 12.5 8.0
## [57,] 4.0 4.0 13.5 9.5
## [58,] 0.5 5.5 5.0 2.5
## [59,] 7.5 6.0 12.0 4.5
## [60,] 10.0 1.5 10.0 10.5
## [61,] 5.0 5.5 10.0 0.5
## [62,] 2.0 3.0 1.0 9.5
## [63,] 0.5 1.5 10.5 9.0
## [64,] 3.0 1.5 5.0 1.0
## [65,] 3.0 6.5 10.5 2.0
## [66,] 2.0 3.0 1.0 8.0
## [67,] 5.0 7.0 3.0 10.5
## [68,] 5.0 6.0 6.0 2.0
## [69,] 3.0 5.5 7.5 8.0
## [70,] 2.0 8.0 10.5 4.5
## [71,] 0.5 3.0 9.5 0.0
## [72,] 3.0 6.5 8.0 4.5
## [73,] 3.0 6.0 10.0 9.0
## [74,] 1.5 8.0 2.0 2.0
## [75,] 0.5 5.5 2.0 4.5
## [76,] 3.0 4.0 8.0 4.0
## [77,] 3.0 8.0 10.0 1.5
## [78,] 0.5 6.5 7.0 8.0
## [79,] 1.0 5.5 12.5 4.5
## [80,] 1.0 6.0 12.0 4.5
## [81,] 2.0 6.5 10.5 7.0
## [82,] 1.5 8.0 2.0 8.0
## [83,] 3.0 3.5 5.0 8.0
## [84,] 3.0 3.0 4.0 10.0
## [85,] 3.0 1.5 10.0 6.0
## [86,] 3.0 6.5 10.0 8.0
## [87,] 3.0 6.5 10.5 4.0
## [88,] 1.0 1.5 10.0 8.0
## [89,] 3.0 5.5 4.0 8.0
## [90,] 3.0 5.5 12.5 11.0