Kelton Chapter 6 Problems

For Problem 1,2 and 3 I ahve used the Stst::Fit software.

6.5.1

Problem 1 in Stat::Fit

Problem 1 in Stat::Fit

For this problem Expotential distribution is recommended.

P-P Plot

P-P Plot

Correct Simio expression:

Exponential(2.06, 9.86)


6.5.2

Problem 2 in Stat::Fit

Problem 2 in Stat::Fit

For this problem Lognormal distribution is recommended.

P-P Plot

P-P Plot

Correct Simio expression:

Lognormal(2.76, 1.84, 0.717)


6.5.3

Problem 3 in Stat::Fit

Problem 3 in Stat::Fit

For this problem Lognormal distribution is recommended.

P-P Plot

P-P Plot

Correct Simio expression:

Lognormal(-0.497, 1.14, 0.439)


6.5.4

CDF for Continuous Uniform Distribution (DES Banks, Chapter 8):

\[ F(x) = \begin{cases} 0, & x < a\\ \ \frac{x - a}{b - a}, & a \leq x \leq b \\ 1, & x > b \end{cases} \]

Inverse Transform, Soving for X in terms of R :

\[X= a + (b-a)R\]


6.5.5

CDF for Continuous Weibull Distribution (DES Banks, Chapter 8):

\[F(x)=1 - e^{-(x/\alpha)^\beta}, x \geq0\]

Inverse Transform, Soving for X in terms of R :

\[X= \alpha[-ln(1-R)]^{1/\beta}\]


6.5.8

# Purchase price
oats.p <- 1.05
peas.p <- 3.17
beans.p <- 1.99
barley.p <- 0.95

# Sale price
oats.s <- 1.29
peas.s <- 3.76
beans.s <- 2.23
barley.s <- 1.65

# Pre-packaged size and their demand probabilities.
lb.demand.oats = data.frame(lb = c(0, 0.5, 1, 1.5, 2.0, 3.0, 4.0, 5.0, 7.5, 10.0),
                            prob = c(0.05, 0.07, 0.09, 0.11, 0.15, 0.25, 0.10, 0.09, 0.06, 0.03))
              
lb.demand.peas = data.frame(lb = c(0, 0.5, 1.0, 1.5, 2.0, 3.0),
                            prob = c(0.1, 0.2, 0.2, 0.3, 0.1, 0.1))

lb.demand.beans = data.frame(lb = c(0, 1.0, 3.0, 4.5),
                             prob = c(0.2, 0.4, 0.3, 0.1))
              
lb.demand.barley = data.frame(lb = c(0, 0.5, 1.0, 3.5),
                              prob = c(0.2, 0.4, 0.3, 0.1))

# Genetate demand for the season(90 days)
oats.sale <- c(sample(lb.demand.oats$lb, prob=lb.demand.oats$prob, 90,replace=TRUE))
peas.sale <- c(sample(lb.demand.peas$lb, prob=lb.demand.peas$prob, 90, replace = TRUE))
beans.sale <- c(sample(lb.demand.beans$lb, prob=lb.demand.beans$prob, 90, replace=TRUE))
barley.sale <- c(sample(lb.demand.barley$lb, prob=lb.demand.barley$prob,90,replace = TRUE))

par(mfrow=c(2,2))
hist(oats.sale, xlab = "pounds", main = "Histogram of Oats Demand(lbs)")
hist(peas.sale, xlab = "pounds", main = "Histogram of peas Demand(lbs)")
hist(beans.sale, xlab = "pounds", main = "Histogram of Beans Demand(lbs)")
hist(barley.sale, xlab = "pounds", main = "Histogram of Barley Demand(lbs)")

oats.cost <- oats.p * oats.sale
peas.cost <- peas.p * peas.sale 
beans.cost <-beans.p * beans.sale
barley.cost <-barley.p * barley.sale

oats.revenue <- oats.s * oats.sale
peas.revenue <- peas.s * peas.sale
beans.revenue <- beans.s * beans.sale
barley.revenue <-barley.s * barley.sale

oats.profit <- oats.revenue - (oats.p * oats.sale)
peas.profit <- peas.revenue - (peas.p * peas.sale)
beans.profit <- beans.revenue -(beans.p * beans.sale)
barley.profit <- barley.revenue - (barley.p * barley.sale)


day <- c(1:90)


df <- data.frame(day, oats.sale, peas.sale, beans.sale, barley.sale, oats.cost, peas.cost, beans.cost, barley.cost, oats.revenue, peas.revenue, beans.revenue, barley.revenue, oats.profit, peas.profit, beans.profit, barley.profit )
colnames(df) <- c("Day", "Oats Demand(lbs)", "Peas Demand(lbs)", "Beans Demand(lbs)", "Barley Demand(lbs)", "Oats Cost($)",  "Peas Cost($)",  "Beans Cost($)",  "Barley Cost($)","Oats Revenue($)", "Peas Revenue($)", "Beans Revenue($)","Barley Revenue($)","Oats Profit($)", "Peas Profit($)", "Beans Profit($)", "Barley Profit($)")

knitr::kable(df)
Day Oats Demand(lbs) Peas Demand(lbs) Beans Demand(lbs) Barley Demand(lbs) Oats Cost($) Peas Cost($) Beans Cost($) Barley Cost($) Oats Revenue($) Peas Revenue($) Beans Revenue($) Barley Revenue($) Oats Profit($) Peas Profit($) Beans Profit($) Barley Profit($)
1 2.0 1.5 3.0 1.0 2.100 4.755 5.970 0.950 2.580 5.64 6.690 1.650 0.48 0.885 0.72 0.70
2 2.0 0.5 3.0 3.5 2.100 1.585 5.970 3.325 2.580 1.88 6.690 5.775 0.48 0.295 0.72 2.45
3 1.5 0.5 1.0 0.0 1.575 1.585 1.990 0.000 1.935 1.88 2.230 0.000 0.36 0.295 0.24 0.00
4 7.5 0.5 1.0 0.5 7.875 1.585 1.990 0.475 9.675 1.88 2.230 0.825 1.80 0.295 0.24 0.35
5 0.5 0.5 4.5 1.0 0.525 1.585 8.955 0.950 0.645 1.88 10.035 1.650 0.12 0.295 1.08 0.70
6 1.0 2.0 3.0 3.5 1.050 6.340 5.970 3.325 1.290 7.52 6.690 5.775 0.24 1.180 0.72 2.45
7 0.0 1.5 1.0 0.5 0.000 4.755 1.990 0.475 0.000 5.64 2.230 0.825 0.00 0.885 0.24 0.35
8 5.0 0.5 3.0 1.0 5.250 1.585 5.970 0.950 6.450 1.88 6.690 1.650 1.20 0.295 0.72 0.70
9 5.0 1.0 0.0 1.0 5.250 3.170 0.000 0.950 6.450 3.76 0.000 1.650 1.20 0.590 0.00 0.70
10 1.0 2.0 1.0 0.5 1.050 6.340 1.990 0.475 1.290 7.52 2.230 0.825 0.24 1.180 0.24 0.35
11 3.0 1.0 4.5 1.0 3.150 3.170 8.955 0.950 3.870 3.76 10.035 1.650 0.72 0.590 1.08 0.70
12 1.5 2.0 3.0 0.5 1.575 6.340 5.970 0.475 1.935 7.52 6.690 0.825 0.36 1.180 0.72 0.35
13 1.5 2.0 0.0 0.5 1.575 6.340 0.000 0.475 1.935 7.52 0.000 0.825 0.36 1.180 0.00 0.35
14 4.0 1.5 1.0 1.0 4.200 4.755 1.990 0.950 5.160 5.64 2.230 1.650 0.96 0.885 0.24 0.70
15 3.0 1.0 4.5 1.0 3.150 3.170 8.955 0.950 3.870 3.76 10.035 1.650 0.72 0.590 1.08 0.70
16 1.0 1.5 1.0 0.0 1.050 4.755 1.990 0.000 1.290 5.64 2.230 0.000 0.24 0.885 0.24 0.00
17 2.0 1.0 4.5 0.5 2.100 3.170 8.955 0.475 2.580 3.76 10.035 0.825 0.48 0.590 1.08 0.35
18 3.0 1.5 3.0 3.5 3.150 4.755 5.970 3.325 3.870 5.64 6.690 5.775 0.72 0.885 0.72 2.45
19 3.0 0.5 1.0 1.0 3.150 1.585 1.990 0.950 3.870 1.88 2.230 1.650 0.72 0.295 0.24 0.70
20 4.0 1.5 3.0 0.0 4.200 4.755 5.970 0.000 5.160 5.64 6.690 0.000 0.96 0.885 0.72 0.00
21 4.0 1.5 1.0 1.0 4.200 4.755 1.990 0.950 5.160 5.64 2.230 1.650 0.96 0.885 0.24 0.70
22 10.0 0.0 0.0 0.5 10.500 0.000 0.000 0.475 12.900 0.00 0.000 0.825 2.40 0.000 0.00 0.35
23 0.0 1.5 3.0 1.0 0.000 4.755 5.970 0.950 0.000 5.64 6.690 1.650 0.00 0.885 0.72 0.70
24 5.0 2.0 3.0 0.5 5.250 6.340 5.970 0.475 6.450 7.52 6.690 0.825 1.20 1.180 0.72 0.35
25 3.0 0.5 3.0 0.5 3.150 1.585 5.970 0.475 3.870 1.88 6.690 0.825 0.72 0.295 0.72 0.35
26 5.0 1.5 1.0 0.0 5.250 4.755 1.990 0.000 6.450 5.64 2.230 0.000 1.20 0.885 0.24 0.00
27 2.0 1.5 1.0 0.5 2.100 4.755 1.990 0.475 2.580 5.64 2.230 0.825 0.48 0.885 0.24 0.35
28 0.0 1.0 1.0 3.5 0.000 3.170 1.990 3.325 0.000 3.76 2.230 5.775 0.00 0.590 0.24 2.45
29 5.0 1.0 1.0 0.5 5.250 3.170 1.990 0.475 6.450 3.76 2.230 0.825 1.20 0.590 0.24 0.35
30 3.0 0.5 3.0 3.5 3.150 1.585 5.970 3.325 3.870 1.88 6.690 5.775 0.72 0.295 0.72 2.45
31 2.0 1.5 3.0 0.5 2.100 4.755 5.970 0.475 2.580 5.64 6.690 0.825 0.48 0.885 0.72 0.35
32 4.0 1.0 4.5 0.5 4.200 3.170 8.955 0.475 5.160 3.76 10.035 0.825 0.96 0.590 1.08 0.35
33 3.0 3.0 4.5 0.0 3.150 9.510 8.955 0.000 3.870 11.28 10.035 0.000 0.72 1.770 1.08 0.00
34 3.0 1.5 3.0 1.0 3.150 4.755 5.970 0.950 3.870 5.64 6.690 1.650 0.72 0.885 0.72 0.70
35 1.5 0.5 1.0 1.0 1.575 1.585 1.990 0.950 1.935 1.88 2.230 1.650 0.36 0.295 0.24 0.70
36 3.0 0.5 0.0 0.0 3.150 1.585 0.000 0.000 3.870 1.88 0.000 0.000 0.72 0.295 0.00 0.00
37 1.5 1.5 4.5 0.5 1.575 4.755 8.955 0.475 1.935 5.64 10.035 0.825 0.36 0.885 1.08 0.35
38 7.5 1.0 0.0 3.5 7.875 3.170 0.000 3.325 9.675 3.76 0.000 5.775 1.80 0.590 0.00 2.45
39 5.0 1.5 0.0 0.5 5.250 4.755 0.000 0.475 6.450 5.64 0.000 0.825 1.20 0.885 0.00 0.35
40 2.0 1.5 3.0 1.0 2.100 4.755 5.970 0.950 2.580 5.64 6.690 1.650 0.48 0.885 0.72 0.70
41 2.0 1.5 3.0 0.5 2.100 4.755 5.970 0.475 2.580 5.64 6.690 0.825 0.48 0.885 0.72 0.35
42 5.0 0.5 1.0 1.0 5.250 1.585 1.990 0.950 6.450 1.88 2.230 1.650 1.20 0.295 0.24 0.70
43 1.5 2.0 1.0 0.0 1.575 6.340 1.990 0.000 1.935 7.52 2.230 0.000 0.36 1.180 0.24 0.00
44 3.0 1.5 1.0 1.0 3.150 4.755 1.990 0.950 3.870 5.64 2.230 1.650 0.72 0.885 0.24 0.70
45 3.0 1.5 4.5 1.0 3.150 4.755 8.955 0.950 3.870 5.64 10.035 1.650 0.72 0.885 1.08 0.70
46 3.0 0.0 0.0 1.0 3.150 0.000 0.000 0.950 3.870 0.00 0.000 1.650 0.72 0.000 0.00 0.70
47 3.0 1.5 0.0 0.5 3.150 4.755 0.000 0.475 3.870 5.64 0.000 0.825 0.72 0.885 0.00 0.35
48 4.0 3.0 1.0 1.0 4.200 9.510 1.990 0.950 5.160 11.28 2.230 1.650 0.96 1.770 0.24 0.70
49 1.0 1.0 0.0 1.0 1.050 3.170 0.000 0.950 1.290 3.76 0.000 1.650 0.24 0.590 0.00 0.70
50 1.0 1.5 3.0 0.5 1.050 4.755 5.970 0.475 1.290 5.64 6.690 0.825 0.24 0.885 0.72 0.35
51 0.5 0.0 4.5 0.0 0.525 0.000 8.955 0.000 0.645 0.00 10.035 0.000 0.12 0.000 1.08 0.00
52 5.0 1.5 3.0 1.0 5.250 4.755 5.970 0.950 6.450 5.64 6.690 1.650 1.20 0.885 0.72 0.70
53 1.5 1.5 3.0 0.5 1.575 4.755 5.970 0.475 1.935 5.64 6.690 0.825 0.36 0.885 0.72 0.35
54 3.0 0.5 3.0 1.0 3.150 1.585 5.970 0.950 3.870 1.88 6.690 1.650 0.72 0.295 0.72 0.70
55 3.0 0.5 1.0 0.5 3.150 1.585 1.990 0.475 3.870 1.88 2.230 0.825 0.72 0.295 0.24 0.35
56 1.5 1.0 3.0 0.5 1.575 3.170 5.970 0.475 1.935 3.76 6.690 0.825 0.36 0.590 0.72 0.35
57 2.0 0.5 4.5 0.0 2.100 1.585 8.955 0.000 2.580 1.88 10.035 0.000 0.48 0.295 1.08 0.00
58 0.0 3.0 1.0 0.5 0.000 9.510 1.990 0.475 0.000 11.28 2.230 0.825 0.00 1.770 0.24 0.35
59 2.0 0.0 3.0 0.0 2.100 0.000 5.970 0.000 2.580 0.00 6.690 0.000 0.48 0.000 0.72 0.00
60 1.5 0.5 1.0 1.0 1.575 1.585 1.990 0.950 1.935 1.88 2.230 1.650 0.36 0.295 0.24 0.70
61 7.5 1.0 0.0 1.0 7.875 3.170 0.000 0.950 9.675 3.76 0.000 1.650 1.80 0.590 0.00 0.70
62 1.0 2.0 4.5 1.0 1.050 6.340 8.955 0.950 1.290 7.52 10.035 1.650 0.24 1.180 1.08 0.70
63 1.0 1.5 0.0 1.0 1.050 4.755 0.000 0.950 1.290 5.64 0.000 1.650 0.24 0.885 0.00 0.70
64 7.5 1.5 1.0 1.0 7.875 4.755 1.990 0.950 9.675 5.64 2.230 1.650 1.80 0.885 0.24 0.70
65 2.0 0.5 3.0 1.0 2.100 1.585 5.970 0.950 2.580 1.88 6.690 1.650 0.48 0.295 0.72 0.70
66 4.0 1.5 0.0 3.5 4.200 4.755 0.000 3.325 5.160 5.64 0.000 5.775 0.96 0.885 0.00 2.45
67 7.5 3.0 4.5 1.0 7.875 9.510 8.955 0.950 9.675 11.28 10.035 1.650 1.80 1.770 1.08 0.70
68 3.0 0.5 0.0 0.0 3.150 1.585 0.000 0.000 3.870 1.88 0.000 0.000 0.72 0.295 0.00 0.00
69 1.5 0.5 3.0 1.0 1.575 1.585 5.970 0.950 1.935 1.88 6.690 1.650 0.36 0.295 0.72 0.70
70 1.0 1.5 0.0 0.5 1.050 4.755 0.000 0.475 1.290 5.64 0.000 0.825 0.24 0.885 0.00 0.35
71 1.0 1.5 1.0 1.0 1.050 4.755 1.990 0.950 1.290 5.64 2.230 1.650 0.24 0.885 0.24 0.70
72 1.0 1.5 3.0 1.0 1.050 4.755 5.970 0.950 1.290 5.64 6.690 1.650 0.24 0.885 0.72 0.70
73 5.0 0.5 1.0 1.0 5.250 1.585 1.990 0.950 6.450 1.88 2.230 1.650 1.20 0.295 0.24 0.70
74 1.5 1.0 1.0 1.0 1.575 3.170 1.990 0.950 1.935 3.76 2.230 1.650 0.36 0.590 0.24 0.70
75 0.5 3.0 1.0 3.5 0.525 9.510 1.990 3.325 0.645 11.28 2.230 5.775 0.12 1.770 0.24 2.45
76 4.0 0.5 3.0 1.0 4.200 1.585 5.970 0.950 5.160 1.88 6.690 1.650 0.96 0.295 0.72 0.70
77 3.0 1.5 4.5 0.5 3.150 4.755 8.955 0.475 3.870 5.64 10.035 0.825 0.72 0.885 1.08 0.35
78 2.0 1.0 1.0 0.5 2.100 3.170 1.990 0.475 2.580 3.76 2.230 0.825 0.48 0.590 0.24 0.35
79 3.0 0.5 0.0 0.0 3.150 1.585 0.000 0.000 3.870 1.88 0.000 0.000 0.72 0.295 0.00 0.00
80 3.0 0.5 1.0 0.0 3.150 1.585 1.990 0.000 3.870 1.88 2.230 0.000 0.72 0.295 0.24 0.00
81 10.0 0.0 1.0 0.0 10.500 0.000 1.990 0.000 12.900 0.00 2.230 0.000 2.40 0.000 0.24 0.00
82 4.0 0.0 0.0 1.0 4.200 0.000 0.000 0.950 5.160 0.00 0.000 1.650 0.96 0.000 0.00 0.70
83 2.0 1.0 1.0 0.5 2.100 3.170 1.990 0.475 2.580 3.76 2.230 0.825 0.48 0.590 0.24 0.35
84 2.0 1.5 3.0 0.0 2.100 4.755 5.970 0.000 2.580 5.64 6.690 0.000 0.48 0.885 0.72 0.00
85 2.0 1.5 3.0 1.0 2.100 4.755 5.970 0.950 2.580 5.64 6.690 1.650 0.48 0.885 0.72 0.70
86 1.5 1.5 1.0 0.0 1.575 4.755 1.990 0.000 1.935 5.64 2.230 0.000 0.36 0.885 0.24 0.00
87 5.0 2.0 1.0 0.5 5.250 6.340 1.990 0.475 6.450 7.52 2.230 0.825 1.20 1.180 0.24 0.35
88 7.5 0.0 0.0 3.5 7.875 0.000 0.000 3.325 9.675 0.00 0.000 5.775 1.80 0.000 0.00 2.45
89 7.5 0.0 3.0 1.0 7.875 0.000 5.970 0.950 9.675 0.00 6.690 1.650 1.80 0.000 0.72 0.70
90 0.0 0.0 0.0 0.0 0.000 0.000 0.000 0.000 0.000 0.00 0.000 0.000 0.00 0.000 0.00 0.00
par(mfrow=c(1,1))

plot(oats.cost, type = "o", col = "red", xlab = "Day", ylab = "Dollars", main = "Oats Cost, Renenue and Profit by Day")
lines(oats.revenue, type = "o", col = "blue")
lines(oats.profit, type = "o", col = "green")

plot(peas.cost, type = "o", col = "red", xlab = "Day", ylab = "Dollars", main = "Peas Cost, Renenue and Profit by Day")
lines(peas.revenue, type = "o", col = "blue")
lines(peas.profit, type = "o", col = "green")

plot(beans.cost, type = "o", col = "red", xlab = "Day", ylab = "Dollars", main = "Beans Cost, Renenue and Profit by Day")
lines(beans.revenue, type = "o", col = "blue")
lines(beans.profit, type = "o", col = "green")

plot(barley.cost, type = "o", col = "red", xlab = "Day", ylab = "Dollars", main = "Barley Cost, Renenue and Profit by Day")
lines(barley.revenue, type = "o", col = "blue")
lines(barley.profit, type = "o", col = "green")

# Total cost, revenue and profit by products in 90 days


# Oats
total.cost.oats <- sum(oats.cost)
total.revenue.oats <- sum(oats.revenue)
total.profit.oats <- sum(oats.profit)

df1 <- data.frame(total.cost.oats, total.revenue.oats, total.profit.oats)
colnames(df1) <- c("Total Oats Cost($)", "Total OatsRevenue($)", "Total Oats Profit($)")
knitr::kable(df1)
Total Oats Cost($) Total OatsRevenue($) Total Oats Profit($)
282.45 347.01 64.56
# Peas

total.cost.peas <- sum(peas.cost)
total.revenue.peas <- sum(peas.revenue)
total.profit.peas <- sum(peas.profit)

df2 <- data.frame(total.cost.peas, total.revenue.peas, total.profit.peas)
colnames(df2) <- c("Total Peas Cost($)", "Total Peas Revenue($)", "Total Peas Profit($)")
knitr::kable(df2)
Total Peas Cost($) Total Peas Revenue($) Total Peas Profit($)
329.68 391.04 61.36
total.cost.beans <- sum(beans.cost)
total.revenue.beans <- sum(beans.revenue)
total.profit.beans <- sum(beans.profit)

df3 <- data.frame(total.cost.beans, total.revenue.beans, total.profit.beans)
colnames(df3) <- c("Total Beans Cost($)", "Total Beans Revenue($)", "Total Beans Profit($)")
knitr::kable(df3)
Total Beans Cost($) Total Beans Revenue($) Total Beans Profit($)
345.265 386.905 41.64
total.cost.barley <- sum(barley.cost)
total.revenue.barley <- sum(barley.revenue)
total.profit.barley <- sum(barley.profit)

df4 <- data.frame(total.cost.barley, total.revenue.barley, total.profit.barley)
colnames(df4) <- c("Total Barley Cost($)", "Total Barley Revenue($)", "Total Barley Profit($)")
knitr::kable(df4)
Total Barley Cost($) Total Barley Revenue($) Total Barley Profit($)
77.9 135.3 57.4