### Handout 1 # Problem 1.3 # start web based help help.start() # enter data x <- c(0.74, 0.647, 1.90, 2.69, 0.75, 0.32, 9.99, 1.77, 2.41, 1.96, 1.66, 0.70, 2.42, 0.54, 3.36, 3.59, 0.37, 1.09, 8.32, 4.06, 4.55, 0.76, 2.03, 5.70, 12.48) # compute the sample size n <- length(x) # get help on hist(), the command to produce a histogram help(hist) # plot a frequency histogram X11() hist(x, freq = TRUE) # plot a relative frequency histogram X11() hist(x, freq = FALSE) # Problem 1.12 # a. # get help on mean() help(mean) # get help on sd() help(sd) # Compute the mean and sd of x x.mean <- mean(x) x.mean x.sd <- sd(x) x.sd # b. x.1u <- x.mean + x.sd x.1u x.1d <- x.mean - x.sd x.1d x.2u <- x.mean + 2*x.sd x.2u x.2d <- x.mean - 2*x.sd x.2d x.3u <- x.mean + 3*x.sd x.3u x.3d <- x.mean - 3*x.sd x.3d # count numer of observations in each interval Count1 <- 0 for(i in 1:n){ if((x[i] < x.1u) && (x[i] > x.1d)) Count1 <- Count1 + 1 } Count1 Count1/n Count2 <- 0 for(i in 1:n){ if((x[i] < x.2u) && (x[i] > x.2d)) Count2 <- Count2 + 1 } Count2 Count2/n Count3 <- 0 for(i in 1:n){ if((x[i] < x.3u) && (x[i] > x.3d)) Count3 <- Count3 + 1 } Count3 Count3/n