Key_Lab1

pdf

School

Drexel University *

*We aren’t endorsed by this school

Course

410

Subject

Statistics

Date

Feb 20, 2024

Type

pdf

Pages

3

Uploaded by ChiefOtter2846

Report
9/27/23, 2:03 PM Lab 162 file:///Users/zacharykey/Key_Lab1.html 1/3 Lab 162 2023-09-27 Excerise 3.1 3.1.1 Generate a list … sample(1:10,7,replace=F) ## [1] 10 9 6 4 1 3 5 I ran this several times. 3.1.2 sample(1:10,7,replace=T) ## [1] 6 10 6 4 7 7 6 I ran this serveral times until I got two 9s. 3.1.3 I expect that it will either not run or randomly pick 10 numbers as there cannot be any duplicates. 2+1 ## [1] 3 I had to remove the error sample(1:10,15,replace=F) as it wasn’t letting me Knit it. 3.1.4 cod_data=c(6,12,7,9,15,8,7,11,20,10,8,18,5,12,7,8,5,15,10,9,5,8,72,7,21,10,12,9,6,6,14,1 2,21,11,5,9,6,12,8,8,12,6,9,4,19,32,9,11,16,5) Select = sample(cod_data,5,replace=F) mean(Select) ## [1] 10.6
9/27/23, 2:03 PM Lab 162 file:///Users/zacharykey/Key_Lab1.html 2/3 The difference in averages was because some cod were much more heavier than the rest. If those were included in the averages it would raise it. 3.3 data=c(1,2,3,4,5) 3.3.1 LogTest = c(1,10,100,1000,10000) log10(LogTest) ## [1] 0 1 2 3 4 I was able to take the log10 of the data set called LogTest. 3.3.2 rank(cod_data) ## [1] 9.0 36.5 13.5 24.5 41.5 18.5 13.5 32.0 46.0 29.0 18.5 44.0 4.0 36.5 13.5 ## [16] 18.5 4.0 41.5 29.0 24.5 4.0 18.5 50.0 13.5 47.5 29.0 36.5 24.5 9.0 9.0 ## [31] 40.0 36.5 47.5 32.0 4.0 24.5 9.0 36.5 18.5 18.5 36.5 9.0 24.5 1.0 45.0 ## [46] 49.0 24.5 32.0 43.0 4.0 The rank function ranks the data by placing the rank where the number is in the vector. If there are multiple numbers it takes the median rank of them. 3.3.3 cod_data[1:5] ## [1] 6 12 7 9 15 Was able to find the first five numbers in the cod data with a single line of code. 3.4 data=c(1,3,5,7,9,11,13,15,17,19) data=data+1 location=sample(1:10,1,replace=F) data[location]
9/27/23, 2:03 PM Lab 162 file:///Users/zacharykey/Key_Lab1.html 3/3 ## [1] 8 First the data set was label as data. Then the values changed with the addition of data+1. Then a a new label location was added and given thew function to find a number between 1 and 10. Then the function “location” was added to the data set to find a number between 1-10 in that set. Last problem sample(cod_data,10,replace=F) ## [1] 12 9 5 12 20 12 18 9 8 72 I ran a code that randomly selected 10 cod and outputted their weights.
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