library(ggplot2)
library(tidyr)
library(dplyr)
library(knitr)
library(gridExtra)
library(latex2exp)
library(reshape2)
library(kableExtra)

Section 2.1

Page 121: #2

For each of the following data sets, formulate the mathematical model that minimizes the largest deviation between the data and the line y D axCb. If a computer is available, solve for the estimates of a and b.

Part A.

x y
1.0 3.6
2.3 3.0
3.7 3.2
4.2 5.1
6.1 5.3
7.0 6.8
solve the estimates for a and b using Least Square Method
## 
## Call:
## lm(formula = y ~ x)
## 
## Coefficients:
## (Intercept)            x  
##      2.2149       0.5642

\(Slope:\) 0.5642

\(Intercept:\) 2.2148

Page 135: #7

Part A.

In the following data, W represents the weight of a fish (bass) and l represents its length. Fit the model W D kl3 to the data using the least-squares criterion.

l w
14.500 27
12.500 17
17.250 41
14.500 26
12.625 17
17.750 49
14.125 23
12.625 16
## [1] 12.16834

Part B.

In the following data, g represents the girth of a fish. Fit the model W D klg2 to the data using the least-squares criterion.

l w g
14.500 27 9.750
12.500 17 8.375
17.250 41 11.000
14.500 26 9.750
12.625 17 8.500
17.750 49 12.500
14.125 23 9.000
12.625 16 8.500

\(w = { kl^3}\) \(k = \frac{\Sigma l_i^3 w_i}{\Sigma l_i^{6}}\)

## [1] 17.6711

Part C.

Which of the two models fits the data better? Justify fully. Which model do you prefer? Why?

Solution:

The model that fits the data better, would have to be the first Model. This is due to the fact that the Sum of Squares Error is lower for Model 1.

Page 135: #7

construct a scatterplot of the given data. Is there a trend in the data? Are any of the data points outliers? Construct a divided difference table. Is smoothing with a low-order polynomial appropriate? If so, choose an appropriate polynomial and fit using the least-squares criterion of best fit. Analyze the goodness of fit by examining appropriate indicators and graphing the model, the data points, and the deviations.

The following data represent the length of a bass fish and its weight.

length weight
12.500 17.0
12.625 16.5
14.125 23.0
14.500 26.5
17.250 41.0
17.750 49.0
length weight delta1 delta2 delta3 delta4 delta5
12.500 17.0 -4.000000 5.128205 -1.2307692 0.0785774 0.0640672
12.625 16.5 4.333333 2.666667 -0.8575266 0.4149303 0.0000000
14.125 23.0 9.333333 -1.299394 1.2689912 0.0000000 0.0000000
14.500 26.5 5.272727 3.300699 0.0000000 0.0000000 0.0000000
17.250 41.0 16.000000 0.000000 0.0000000 0.0000000 0.0000000
17.750 49.0 0.000000 0.000000 0.0000000 0.0000000 0.0000000

As seen from the plot the number of observations are less, so it is difficult to detect outliers in this scatter plot

Section 2.1

Page 194: #1

Use the middle-square method to generate:

Part A.

10 random numbers using \(x_0\) = 1009.

##  [1] 1009  180  324 1049 1004   80   64   40   16    2    0

Part B.

20 random numbers using \(x_0\) = 653217.

##  [1] 653217 692449 485617 823870 761776 302674 611550 993402 847533 312186
## [11] 460098 690169 333248  54229 940784  74534 555317 376970 106380 316704
## [21] 301423

Part C.

15 random numbers using \(x_0\) = 3043.

##  [1] 3043 2598 7496 1900 6100 2100 4100 8100 6100 2100 4100 8100 6100 2100 4100
## [16] 8100

Part D.

Comment about the results of each sequence. Was there cycling? Did each sequence degenerate rapidly?

Solution:

In sequence ‘a’, degenerated to 0 was fairly quick within 10 iterations.

In sequence ‘b’, did not degenerate or cycle after 20 iterations.

In Sequence ‘c’, it cycles after hitting 6100 on the 4th iteration. Then repeats the cycle at 6100, 2100, 4100, 8100.

Page 211: #3

In many situations, the time T between deliveries and the order quantity Q is not fixed. Instead, an order is placed for a specific amount of gasoline. Depending on how many orders are placed in a given time interval, the time to fill an order varies. You have no reason to believe that the performance of the delivery operation will change. Therefore, you have examined records for the past 100 deliveries and found the following lag times, or extra days, required to fill your order:

Lag Time # of Occurrences
2 10
3 25
4 30
5 20
7 13
7 2
-
Total 100

Construct a Monte Carlo simulation for the lag time submodel. If you have a handheld calculator or computer available, test your submodel by running 1000 trials and comparing the number of occurrences of the various lag times with the historical data.