Master-DataScience-Notes/2year/1trimester/Advanced Multivariate Statistics/Assignment/assignment1/assignment1.R

43 lines
531 B
R
Raw Normal View History

2020-09-28 20:14:08 +02:00
#Homework - Sept 27, 2020 - Advanced Multivariate Statistics
#=============
#Part.a)
2020-09-29 16:53:38 +02:00
f = function(x)
{
(x>=0 & x <= 7) * 1/7
}
2020-09-28 20:14:08 +02:00
#(i)
2020-09-29 16:53:38 +02:00
integrate(f, lower = -Inf , upper = Inf)
2020-09-28 20:14:08 +02:00
#(ii)
2020-09-29 16:53:38 +02:00
curve(f, from= -5, to= 12)
2020-09-28 20:14:08 +02:00
#(iii)
#The random variable is X
#(iv)
2020-09-29 16:53:38 +02:00
library(distr6)
d = distr6::Uniform$new(lower = 0 , upper = 7)
2020-09-28 20:14:08 +02:00
d$mgf(t = 1)
#=============
#Part.c)
x1 = c(12,11,8,14,10)
x2 = c(10,8,5,11,7)
x3= c(8,11,11,13,6)
m = matrix(c(x1,x2,x3), ncol = 3)
vector_means = c(mean(x1), mean(x2), mean(x3))
vector_means
cov(m)