Paired Observations

Example 13.5 Six similar workloads were used on two systems. The observations are {(5.4, 19.1), (16.6, 3.5), (0.6, 3.4), (1.4, 2.5), (0.6, 3.6), (7.3, 1.7)}. Is one system better than the other?

x <- c(5.4,16.6,0.6,1.4,0.6,7.3)
y <- c(19.1,3.5,3.4,2.5,3.6,1.7)
d <- x-y
m <- mean(d)
s <- sd(d)
n <- length(d)
df <- n-1
t <- qt(0.95,df=df)
lower <- m - t*s/sqrt(n)
upper <- m + t*s/sqrt(n)

Sample mean: -0.3166667
Sample standard deviation: 9.034471
Degrees of freedom: 5
t-variate: 2.0150484
90% confidence interval = (-7.7487844, 7.1154511)

t.test(d,conf.level = 0.9)
## 
##  One Sample t-test
## 
## data:  d
## t = -0.0859, df = 5, p-value = 0.9349
## alternative hypothesis: true mean is not equal to 0
## 90 percent confidence interval:
##  -7.748784  7.115451
## sample estimates:
##  mean of x 
## -0.3166667

Unpaired Observations

Example 13.6 The processor time required to execute a task was measured on two systems. The times on system A were {5.36, 16.57, 0.62, 1.41, 0.64, 7.26}. The times on system B were {19.12, 3.52, 3.38, 2.50, 3.60, 1.74}. Are the two systems significantly different?

A <- c(5.36, 16.57, 0.62, 1.41, 0.64, 7.26)
B <- c(19.12, 3.52, 3.38, 2.50, 3.60, 1.74)

# Compute the sample means:
ma <- mean(A)
mb <- mean(B)

# Compute the sample standard deviations:
sa <- sd(A)
sb <- sd(B)

# Compute the mean difference
d <- ma-mb

# Compute the standard deviation of the mean difference
na <- length(A)
nb <- length(B)
s <- sqrt(sa^2/na + sb^2/nb)

# Compute the effective number of degrees of freedom

v = (sa^2/na + sb^2/nb)^2/(((1/(na-1))*(sa^2/na)^2)+ ((1/(nb-1))*(sb^2/nb)^2))-2

# Compute the confidence interval for the mean difference

t <- qt(0.95,round(v))
lower <- d-t*s
upper <- d+t*s

The confidence interval is (-7.209062,6.5423954)

One Sided Confidence Interval

Example 13.8 Time between crashes was measured for two systems A and B. The mean and standard deviations of the time are listed in Table 13.1. To check if System A is more susceptible to failures than System B, we use the procedure of unpaired observations.

System Number Mean Standard deviation
A 972 124.10 198.20
B 153 141.47 226.11
# Compute means
ma <- df$Mean[1]
mb <- df$Mean[2]

# Compute mean difference
d <- ma-mb

# Compute standard deviation of the mean difference
sa <- df$'Standard deviation'[1]
sb <- df$'Standard deviation'[2]
na <- df$Number[1]
nb <- df$Number[2]
s <- sqrt(sa^2/na + sb^2/nb)

# Compute effective degrees of freedom
v = (sa^2/na + sb^2/nb)^2/(((1/(na-1))*(sa^2/na)^2)+ ((1/(nb-1))*(sb^2/nb)^2))-2
v
## [1] 188.5548
# This is more than 30 so we use z table
z <- qnorm(.9)
upper <- d + z * s

The inteval is \((-\infty, 7.4329057)\)
Since this includes 0 we can reject the hypothesis that System A is more susceptible to crashes than System B.

Determining sample size needed

We use the formula \(n=\left(\frac{100 z s}{r \bar{x}}\right)^2\) where \(r\) is the accuracy desired

Example 13.11 Based on a preliminary test, the sample mean of the response time is 20 seconds, and the sample standard deviation is 5. How many repetitions are needed to get the response time accurate within 1 second at 95% confidence?

We know we want the accuracy to be 1 second and the mean is 20 seconds to 1 second is 5% of 20 seconds so r is 5.

m = 20
s = 5
r = 5
z = qnorm(.975)
n = ceiling(((100*z*s)/(r*m))^2)

So we need 97 observations.

For proprtions we use the equation \(n=z^2\frac{p(1-p)}{r^2}\)

Example 13.12 A preliminary measurement of a laser printer showed an illegible print rate of 1 in 10,000. How many pages must be observed to get an accuracy of 1 per million at 95% confidence?

p=1/10000
r=1/1000000
z = qnorm(.975)
z = 1.96
n = ceiling(z^2*p*(1-p)/r^2)

So we need to pring 384,121,584 pages.