In: Statistics and Probability
3. [5+5+1=11 pts]
a. Draw a frequency histogram for “Temp” variable from “airquality” data. Use breaks=seq(55,
100, 5) in your hist() function. Show frequency on top of each bar. Paste your graph below.
b. Draw a relative frequency histogram for “Temp” variable from “airquality” data using the
same ‘breaks’ parameter. Add a density curve to it. Paste your graph below.
c. What kind of distribution does the data exhibit? Right skewed? Left skewed? Symmetric?
Solution-A:
use hist function in R ,with breaks inside hist set breaks=seq(55, 100, 5),Give title for histogram in main inside quotes.
Give the labels for x axis with xlab and set color of your choice with col
Rcode:
hist_temp <- hist(airquality$Temp,breaks=seq(55, 100,
5),main="Histogram for temperature ",
xlab="Temp",col="green",
border="orange")
text(hist_temp$mids,hist_temp$counts,labels=hist_temp$counts,
adj=c(0.005, -0.005))
Output:
Solution-b:
Rcode:
hist(airquality$Temp,breaks=seq(55, 100, 5),prob=T,main="Density
curve Temperature",col="green",
border="orange", xlab="Temp")
lines(density(airquality$Temp,na.rm=T),col="blue",lwd=4)
c. What kind of distribution does the data exhibit? Right skewed? Left skewed? Symmetric?
From histogram and density we could see that sample follow normal distribution
shape is symmetric