In a class there are 20 students: 3 are 5’ 6“, 5 are 5’8”, 4 are 5’10“, 4 are 6’, and 4 are 6’ 2”. A student is chosen at random. What is the student’s expected height?
Since all student have the same probablities to be chosen randomly, expected value of height = average of height
ToInch <- function(ft,inch) {
return (ft*12 + inch)
}
ToFt <- function(inch) {
return(round(inch/12,2))
}
print(
paste0("Average height of all students: "
,
ToFt((4*ToInch(5,6) + 5* ToInch(5,8) + 4*ToInch(5,10) + 4*ToInch(6,0) + 4*ToInch(6,2))/20)
)
)
## [1] "Average height of all students: 6.12"