# SOAL NO. 3.8
# Masukkan Data
nilai <- c(127,125,131,124,129,121,142,151,160,125,124,123,120,119,128,133,137,124,142,123,121,136,140,137,125,124,128,129,130,122,118,131,125,133,141,125,140,131,129,126)
#Rata-rata dan Standar Deviasi
mean(nilai)
## [1] 129.975
sd(nilai)
## [1] 8.914084
#Median dan Kuartil Lower & Upper
median(nilai)
## [1] 128
quantile(nilai, probs = c(0.25, 0.75), type = 6)
##    25%    75% 
## 124.00 135.25
#Histogram
hist(nilai, 
     main = "Histogram Failure Time", 
     xlab = "Jam", 
     col = "blue")

#Diagram Batang Daun
stem(nilai)
## 
##   The decimal point is 1 digit(s) to the right of the |
## 
##   11 | 89
##   12 | 0112334444
##   12 | 555556788999
##   13 | 011133
##   13 | 677
##   14 | 00122
##   14 | 
##   15 | 1
##   15 | 
##   16 | 0
# SOAL NO. 3.10
# Input Data 
vis <- c(13.3,14.5,15.3,15.3,14.3,14.8,15.2,14.5,14.6,14.1,14.3,16.1,13.1,15.5,12.6,14.6,14.3,15.4,15.2,16.8,14.9,13.7,15.2,14.5,15.3,15.6,15.8,13.3,14.1,15.4,15.2,15.2,15.9,16.5,14.8,15.1,17.0,14.9,14.8,14.0,15.8,13.7,15.1,13.4,14.1,14.8,14.3,14.3,16.4,16.9,14.2,16.9,14.9,15.2,14.4,15.2,14.6,16.4,14.2,15.7,16.0,14.9,13.6,15.3,14.3,15.6,16.1,13.9,15.2,14.4,14.0,14.4,13.7,13.8,15.6,14.5,12.8,16.1,16.6,15.6)

#Diagram Batang Daun
stem(vis)
## 
##   The decimal point is at the |
## 
##   12 | 68
##   13 | 1334
##   13 | 677789
##   14 | 0011122333333444
##   14 | 555566688889999
##   15 | 1122222222333344
##   15 | 566667889
##   16 | 011144
##   16 | 56899
##   17 | 0
# Tabel Frekuensi dan Histogram
n <- length(vis)
jangkauan <- max(vis) - min(vis)
sturgess <- 1 + 3.3 * log10(n)
kelas <- round(sturgess)
breaks <- seq(min(vis), max(vis), length.out = kelas + 1)
as.data.frame(table(cut(vis, breaks = breaks)))
##          Var1 Freq
## 1 (12.6,13.2]    2
## 2 (13.2,13.9]    8
## 3 (13.9,14.5]   17
## 4 (14.5,15.1]   17
## 5 (15.1,15.7]   20
## 6 (15.7,16.4]    7
## 7   (16.4,17]    8
#Histogram
hist(vis, 
     breaks = breaks, 
     main = "VISKOSITAS", 
     xlab = "Viscosity", 
     ylab = "Frequency", 
     col = "red", 
     border = "black")

#Ordered diagram batang daun , Median, & Quartil 1 dan 3
stem(vis)
## 
##   The decimal point is at the |
## 
##   12 | 68
##   13 | 1334
##   13 | 677789
##   14 | 0011122333333444
##   14 | 555566688889999
##   15 | 1122222222333344
##   15 | 566667889
##   16 | 011144
##   16 | 56899
##   17 | 0
median(vis)
## [1] 14.9
quantile(vis, probs = c(0.25, 0.75), type = 6)
##    25%    75% 
## 14.300 15.575
#10  and 90 Percentiles
quantile(vis, probs = c(0.10, 0.90), type = 6)
##   10%   90% 
## 13.70 16.37