Exam 1 (lab 4)

pdf

School

Drexel University *

*We aren’t endorsed by this school

Course

410

Subject

Statistics

Date

Jan 9, 2024

Type

pdf

Pages

18

Uploaded by MegaOysterMaster676

Report
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 1 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html Exam 1 (lab 4) Mathew H 2023-10-18 library (magrittr) library (formattable) library (LearningStats) library (knitr) Question 1: CONFRIRMATION NEEDED #Manual Rankings: Pond ID: Ranking: _________ ________ 1 7 (tie) 2 10 3 6 4 7 (tie) 5 3 (tie) 6 5 7 1 (tie) 8 11 9 1 (tie) 10 3 (tie) 11 7 (tie) #R rankings bullfrogs=c(34,65,23,34,18,20,15,70,15,18,34) rank(bullfrogs) ## [1] 8.0 10.0 6.0 8.0 3.5 5.0 1.5 11.0 1.5 3.5 8.0 ##The ranking is the same, although R delineates ties by outputting a .5 value. Question 2: student_data=read.csv("/Users/mathabib/Documents/R files/Exam1/Student Data.csv") malepulse=student_data$Pulse[1:77] hist(malepulse,breaks=15,main="male pulses",col="blue",xlim=c(40,150),ylim=c(0,20),xl ab="pulse")
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 2 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html femalepulse=student_data$Pulse[78:165] hist(femalepulse,breaks=15,main="female pulses",col="pink",xlim=c(40,150),ylim=c(0,2 0),xlab="pulse")
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 3 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html ## The distributions are not similar. While both seem to be centralized around a pulse of 80, the female distribution is much more broad, with both lower minimums and higher maximums than are observed in the male pulse graph. Question 3: bass=read.csv("/Users/mathabib/Documents/R files/Exam1/bass.csv") bassL=bass$length.mm. bins=seq(60,460,by=10) hist(bassL,breaks=bins,main="frequency of bass lengths",col="green",xlim=c(50,550),xl ab="lengths in mm")
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
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 4 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html #table bins=seq(60,460,by=10) cutbassL=cut(bassL,bins) basstable=transform(table(cutbassL)) names(basstable)[1]="length in mm |" names(basstable)[2]="Frequency" formattable(basstable)%>% kable("html",escape=F,caption="lengths of largemouth") lengths of largemouth length in mm |Frequency (60,70] 2 (70,80] 0 (80,90] 1 (90,100] 1 (100,110] 0 (110,120] 3
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 5 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html (120,130] 1 (130,140] 1 (140,150] 0 (150,160] 1 (160,170] 2 (170,180] 6 (180,190] 3 (190,200] 9 (200,210] 5 (210,220] 1 (220,230] 0 (230,240] 2 (240,250] 3 (250,260] 2 (260,270] 2 (270,280] 0 (280,290] 4 (290,300] 3 (300,310] 4 (310,320] 8 (320,330] 6 (330,340] 4 (340,350] 4 (350,360] 2 (360,370] 5 (370,380] 2 (380,390] 2 (390,400] 3 (400,410] 2 (410,420] 3 (420,430] 0 (430,440] 2 (440,450] 0 (450,460] 1 Question 4:
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 6 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html #table basscumulative=cumsum(table(cutbassL)) cumulativecolumn=transform(basscumulative)$X_data cumulativebasstable=data.frame(basstable,cumulativecolumn) names(cumulativebasstable)[1]="lengths in mm |" names(cumulativebasstable)[2]="frequency |" names(cumulativebasstable)[3]="cumulative frequency" formattable(cumulativebasstable)%>% kable("html",escape=F,caption="lengths of largemouth") lengths of largemouth lengths in mm |frequency |cumulative frequency (60,70] 2 2 (70,80] 0 2 (80,90] 1 3 (90,100] 1 4 (100,110] 0 4 (110,120] 3 7 (120,130] 1 8 (130,140] 1 9 (140,150] 0 9 (150,160] 1 10 (160,170] 2 12 (170,180] 6 18 (180,190] 3 21 (190,200] 9 30 (200,210] 5 35 (210,220] 1 36 (220,230] 0 36 (230,240] 2 38 (240,250] 3 41 (250,260] 2 43 (260,270] 2 45 (270,280] 0 45 (280,290] 4 49 (290,300] 3 52 (300,310] 4 56 (310,320] 8 64 (320,330] 6 70 (330,340] 4 74 (340,350] 4 78 (350,360] 2 80
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
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 7 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html (360,370] 5 85 (370,380] 2 87 (380,390] 2 89 (390,400] 3 92 (400,410] 2 94 (410,420] 3 97 (420,430] 0 97 (430,440] 2 99 (440,450] 0 99 (450,460] 1 100 #histogram hist(cumsum(table(cutbassL)),breaks=25,main="cumulative bass length frequency histogr am",col="darkolivegreen",xlim=c(0,100),xlab="cumulative lengths")
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 8 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html #polygon plot(cumsum(table(cutbassL)),xlab="Cumulative lengths",ylab="cumulative frequencies", main="cumulative bass length frequency polygon") polygon(c(0,cumsum(table(cutbassL)),0),col="darkolivegreen") Question 5: kingfisher=read.csv("/Users/mathabib/Documents/R files/Exam1/kingfisher.csv") kingL=kingfisher$Bill_length mean(kingL) ## [1] 55.69762 median(kingL) ## [1] 56.5
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 9 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html #mode table(kingL) ## kingL ## 47 47.8 48 48.1 48.8 50.1 50.4 50.8 51 51.8 52.3 52.5 53.4 55.2 55.6 55.8 ## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ## 56 56.2 56.3 56.5 56.8 57.1 57.5 57.7 57.8 58 59.2 59.3 59.8 59.9 60.2 61.1 ## 1 1 1 2 3 1 1 1 1 1 2 2 1 1 1 1 ## 61.2 61.5 61.8 62.4 ## 1 1 1 1 ## mode is 56.8 with 3 appearances #range range(kingL)[2]-range(kingL)[1] ## [1] 15.4 IQR(kingL) ## [1] 6.85 var(kingL) ## [1] 18.43097 sd(kingL) ## [1] 4.293131 #coeff var. (sd(kingL))/(mean(kingL)) ## [1] 0.07707925 boxplot(kingL,col="red",main="Kingfisher bill length",ylab="bill length")
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
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 10 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html Mean: 55.69762 Median: 56.5 Mode: 56.8 (3 occurrences) Range: 15.4 IQR: 6.85 Variance: 18.43097 SD: 4.293131 Coe cient of Variation: 0.07707925 Question 6: shell_L=c(95,105,115,125,135,145,155,165) shellwt=c(4,10,9,6,9,3,5,1) weighted.mean(shell_L,shellwt) ## [1] 123.5106 #The weighted mean comes out to 123.5106, which is very close to the actual computed mean of 123.6. The wieghted mean is less than a tenth of a mm o ff of the computed mean. Question 7:
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 11 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html mosquitofish=read.csv("/Users/mathabib/Documents/R files/Exam1/Mosquitofish(1).csv") mmfish=mosquitofish$FishLength[1:854] tenfish1=sample(mmfish,10,replace=F) tenfish2=sample(mmfish,10,replace=F) tenfish3=sample(mmfish,10,replace=F) tenfish4=sample(mmfish,10,replace=F) tenfish5=sample(mmfish,10,replace=F) twentyfish1=sample(mmfish,20,replace=F) twentyfish2=sample(mmfish,20,replace=F) twentyfish3=sample(mmfish,20,replace=F) twentyfish4=sample(mmfish,20,replace=F) twentyfish5=sample(mmfish,20,replace=F) thirtyfish1=sample(mmfish,30,replace=F) thirtyfish2=sample(mmfish,30,replace=F) thirtyfish3=sample(mmfish,30,replace=F) thirtyfish4=sample(mmfish,30,replace=F) thirtyfish5=sample(mmfish,30,replace=F) #Tenfish mean(tenfish1) ## [1] 24 sd(tenfish1) ## [1] 1.699673 mean(tenfish2) ## [1] 23.4 sd(tenfish2) ## [1] 2.412928 mean(tenfish3)
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 12 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html ## [1] 22.4 sd(tenfish3) ## [1] 1.505545 mean(tenfish4) ## [1] 22.8 sd(tenfish4) ## [1] 2.347576 mean(tenfish5) ## [1] 23.3 sd(tenfish5) ## [1] 2.002776 #Twentyfish mean(twentyfish1) ## [1] 24 sd(twentyfish1) ## [1] 3.077935 mean(twentyfish2) ## [1] 23.8
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
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 13 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html sd(twentyfish2) ## [1] 2.764436 mean(twentyfish3) ## [1] 24.55 sd(twentyfish3) ## [1] 3.103055 mean(twentyfish4) ## [1] 24.45 sd(twentyfish4) ## [1] 1.932411 mean(twentyfish5) ## [1] 23.7 sd(twentyfish5) ## [1] 2.792848 #Thirtyfish mean(thirtyfish1) ## [1] 23.7 sd(thirtyfish1)
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 14 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html ## [1] 2.718392 mean(thirtyfish2) ## [1] 22.96667 sd(thirtyfish2) ## [1] 2.918234 mean(thirtyfish3) ## [1] 23.6 sd(thirtyfish3) ## [1] 2.372253 mean(thirtyfish4) ## [1] 22.83333 sd(thirtyfish4) ## [1] 2.841604 mean(thirtyfish5) ## [1] 23.56667 sd(thirtyfish5) ## [1] 2.473073
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 15 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html The means and srandard deviations of the samples are not the same as the population mean and standard deviation. This is because the sample has a much larger size, and therefore has the possibility of having significant outliers that can influence the data. There is a low possibility of including these outliers given the relatively small sample size, so the disparities in mean and sd are observed. Question 8: #A: dbinom(0,25,.10) ## [1] 0.0717898 #B: numblind=0:25 prob=dbinom(numblind,25,0.1) blindtable=data.frame(numblind,prob) names(blindtable)[1]="number of color blind people |" names(blindtable)[2]="probability" formattable(blindtable)%>% kable("html",escape=F,caption="probability of being colorblind") probability of being colorblind number of color blind people |probability 0 0.0717898 1 0.1994161 2 0.2658881 3 0.2264973
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
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 16 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html 4 0.1384150 5 0.0645937 6 0.0239236 7 0.0072150 8 0.0018038 9 0.0003786 10 0.0000673 11 0.0000102 12 0.0000013 13 0.0000001 14 0.0000000 15 0.0000000 16 0.0000000 17 0.0000000 18 0.0000000 19 0.0000000 20 0.0000000 21 0.0000000 22 0.0000000 23 0.0000000 24 0.0000000 25 0.0000000 Question 9: wormspeel=c(0:10) wormsweight=c(17,8,7,6,4,5,3,5,4,3,4) wormsmean=weighted.mean(wormspeel,wormsweight) wormsmean ## [1] 3.530303 #A: n=17 wormprob=dpois(0:n,wormsmean) wormprob ## [1] 2.929604e-02 1.034239e-01 1.825588e-01 2.148293e-01 1.896032e-01 ## [6] 1.338713e-01 7.876772e-02 3.972485e-02 1.753009e-02 6.876283e-03 ## [11] 2.427536e-03 7.790853e-04 2.292006e-04 6.224212e-05 1.569525e-05 ## [16] 3.693933e-06 8.150440e-07 1.692560e-07
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 17 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html wormtotal=sum(wormprob) #B: wormtable=data.frame(0:n,wormprob) names(wormtable)[1]="# of worms. |" names(wormtable)[2]="Probability" formattable(wormtable)%>% kable("html",escape=F,caption="probability of being eels containing x number of wor ms") probability of being eels containing x number of worms # of worms. |Probability 0 0.0292960 1 0.1034239 2 0.1825588 3 0.2148293 4 0.1896032 5 0.1338713 6 0.0787677 7 0.0397248 8 0.0175301 9 0.0068763 10 0.0024275 11 0.0007791 12 0.0002292 13 0.0000622 14 0.0000157 15 0.0000037 16 0.0000008 17 0.0000002 expectedworms=sum(0:n)*wormprob #expected Frequency values actualworms=c(wormsweight,rep(0,n+1-length(wormsweight))) wormtableb=data.frame(0:n,actualworms,expectedworms) names(wormtableb)[1]="worms per eel" names(wormtableb)[2]="observed frequency" names(wormtableb)[3]="expected frequency" wormtableb
10/26/23, 3 : 12 PM Exam 1 (lab 4) Page 18 of 18 file:///Users/mathabib/Documents/R%20files/Exam1/Exam1.html ## worms per eel observed frequency expected frequency ## 1 0 17 4.482294e+00 ## 2 1 8 1.582385e+01 ## 3 2 7 2.793150e+01 ## 4 3 6 3.286889e+01 ## 5 4 4 2.900928e+01 ## 6 5 5 2.048231e+01 ## 7 6 3 1.205146e+01 ## 8 7 5 6.077902e+00 ## 9 8 4 2.682104e+00 ## 10 9 3 1.052071e+00 ## 11 10 4 3.714130e-01 ## 12 11 0 1.192000e-01 ## 13 12 0 3.506769e-02 ## 14 13 0 9.523044e-03 ## 15 14 0 2.401374e-03 ## 16 15 0 5.651718e-04 ## 17 16 0 1.247017e-04 ## 18 17 0 2.589617e-05 The observed and expected frequencies do not match up very well. This suggests that the data set does not fit a poisson distribution very well.
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