40203478_Assignment_3

.pdf

School

Concordia University *

*We aren’t endorsed by this school

Course

280

Subject

Statistics

Date

Jan 9, 2024

Type

pdf

Pages

8

Uploaded by DeaconSalamander3940

Report
Introduction to Statistical Programming: Assignment 3 Marissa Gonçalves (Student ID: 40203478) Textbook Problems Section 2.7 on Page 34 Problem 1 a) # Create a vector containing solar radiation observation data, then display the values # from the vector sample. solar.radiation <- c( 11.1 , 10.6 , 6.3 , 8.8 , 10.7 , 11.2 , 8.9 , 12.2 ) solar.radiation ## [1] 11.1 10.6 6.3 8.8 10.7 11.2 8.9 12.2 b) # Determine the mean, median, range and variance for solar radiation observations by # utilizing appropriate functions. mean(solar.radiation) ## [1] 9.975 median(solar.radiation) ## [1] 10.65 range(solar.radiation) ## [1] 6.3 12.2 var(solar.radiation) ## [1] 3.525 c) The mean, median and range values for sr10 increased by 10, but the variance remains the same as the variance value obtained from solar.radiation data. # Create a variable sr10, which includes all solar radiation observation values added # by 10, then use the mean, median, range and variance functions to calculate needed # values for comparison. sr10 <- solar.radiation + 10 mean(sr10) ## [1] 19.975 median(sr10) ## [1] 20.65 range(sr10) ## [1] 16.3 22.2 1
var(sr10) ## [1] 3.525 d) All mean, median, range and variance values for srm2 differ from solar.radiation data values. # Create a variable srm2, which includes all solar radiation observation values # multiplied by -2, then use the mean, median, range and variance functions to # calculate needed values for comparison. srm2 <- solar.radiation * (- 2 ) mean(srm2) ## [1] -19.95 median(srm2) ## [1] -21.3 range(srm2) ## [1] -24.4 -12.6 var(srm2) ## [1] 14.1 e) # Create three histograms with appropriate titles and unique colour codes to compare # data stored in solar.radiation, sr10, srm2 variables with one another. par( mfrow= c( 1 , 3 )) hist(solar.radiation, main= "Solar Radiation Graph I" , col= "blue" , ylab= "Number of Solar Radiation Observations" , xlab= "Solar Radiation Values" ) hist(sr10, main= "Solar Radiation Graph II" , col= "gold" , ylab= "Number of Solar Radiation Observations" , xlab= "Solar Radiation Values Added by 10" ) hist(srm2, main= "Solar Radiation Graph III" , col= "purple" , ylab= "Number of Solar Radiation Observations" , xlab= "Solar Radiation Values Multiplied by -2" ) 2
Solar Radiation Graph I Solar Radiation Values Number of Solar Radiation Observations 6 8 10 12 14 0 1 2 3 4 Solar Radiation Graph II Solar Radiation Values Added by 10 Number of Solar Radiation Observations 16 18 20 22 24 0 1 2 3 4 Solar Radiation Graph III Solar Radiation Values Multiplied by -2 Number of Solar Radiation Observations -25 -20 -15 -10 0 1 2 3 4 5 Problem 3 # Create variable n as a sequence from 1 to 15, then determine the pairwise maxima # between both 2ˆn and nˆ3, before summing the pairwise value using the function pmax(). n <- 1 : 15 sum(pmax( 2 ˆn, nˆ 3 )) ## [1] 66538 Section 2.9 on Page 46 Problem 2 a) # Utilize the nrow() function to determine the number of rows and the ncol() function # to find the number of columns in the USArrests data frame. According to the results, # there are 50 rows and 4 columns in USArrests built-in data frame. nrow(USArrests) ## [1] 50 ncol(USArrests) ## [1] 4 b) # Utilize the vapply() function to determine the median of each column in the USArrests # data frame. vapply(USArrests, median, 1 ) 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help