RLab1

RLab1 - date

Michela Cameletti www.unibg.it
02-26-2021

Exercise 1

Compute \(\exp(3-\frac{4}{5})+\frac{\sqrt{3+2^5}}{4-7\cdot \log(10))}\)
exp(3-4/5)+ sqrt(3+2^5)/(4-7*log(10))
[1] 8.536811
  1. Create the vector named x which contains the following values \((10, log(0.2), 6/7, exp(4), sqrt(54), -0.124)\):
[1] 10.0000000 -1.6094379  0.8571429 54.5981500  7.3484692 -0.1240000
length(x)
[1] 6

R

How to install RStudio

Install the free version of RStudio for your own operating system from this link: https://rstudio.com/products/rstudio/download/#download. Choose the proper version according to your OS. Proceed as usual and find the icon on your desktop/dock.

Simulate \(n=100\) values from the standard Normal distribution using the following code that will be explained in the following labs. The values are saved in an object named x:
set.seed(123)
x = rnorm(100) 
x
  [1] -0.560475647 -0.230177489  1.558708314  0.070508391  0.129287735
  [6]  1.715064987  0.460916206 -1.265061235 -0.686852852 -0.445661970
 [11]  1.224081797  0.359813827  0.400771451  0.110682716 -0.555841135
 [16]  1.786913137  0.497850478 -1.966617157  0.701355902 -0.472791408
 [21] -1.067823706 -0.217974915 -1.026004448 -0.728891229 -0.625039268
 [26] -1.686693311  0.837787044  0.153373118 -1.138136937  1.253814921
 [31]  0.426464221 -0.295071483  0.895125661  0.878133488  0.821581082
 [36]  0.688640254  0.553917654 -0.061911711 -0.305962664 -0.380471001
 [41] -0.694706979 -0.207917278 -1.265396352  2.168955965  1.207961998
 [46] -1.123108583 -0.402884835 -0.466655354  0.779965118 -0.083369066
 [51]  0.253318514 -0.028546755 -0.042870457  1.368602284 -0.225770986
 [56]  1.516470604 -1.548752804  0.584613750  0.123854244  0.215941569
 [61]  0.379639483 -0.502323453 -0.333207384 -1.018575383 -1.071791226
 [66]  0.303528641  0.448209779  0.053004227  0.922267468  2.050084686
 [71] -0.491031166 -2.309168876  1.005738524 -0.709200763 -0.688008616
 [76]  1.025571370 -0.284773007 -1.220717712  0.181303480 -0.138891362
 [81]  0.005764186  0.385280401 -0.370660032  0.644376549 -0.220486562
 [86]  0.331781964  1.096839013  0.435181491 -0.325931586  1.148807618
 [91]  0.993503856  0.548396960  0.238731735 -0.627906076  1.360652449
 [96] -0.600259587  2.187332993  1.532610626 -0.235700359 -1.026420900
plot
hist(x)