mirror of
https://github.com/Andreaierardi/Master-DataScience-Notes.git
synced 2025-01-10 19:45:58 +01:00
61 lines
994 B
R
61 lines
994 B
R
|
f = function(x)
|
||
|
{
|
||
|
if(x>=0 & x <= 7)
|
||
|
{
|
||
|
1/7
|
||
|
}
|
||
|
else
|
||
|
{0}
|
||
|
}
|
||
|
f(0)
|
||
|
f(-1)
|
||
|
f(7)
|
||
|
f(8)
|
||
|
ibrary(distr6)
|
||
|
d = distr6::Uniform$new(lower = 0 , upper = 7)
|
||
|
#(i)
|
||
|
integrate(d$pdf, lower = -Inf , upper = Inf)
|
||
|
ibrary(distr6)
|
||
|
d = distr6::Uniform$new(lower = 0 , upper = 7)
|
||
|
#(i)
|
||
|
integrate(f, lower = -Inf , upper = Inf)
|
||
|
f = function(x)
|
||
|
{
|
||
|
(x>=0 & x <= 7) * 1/7
|
||
|
}
|
||
|
f(2)
|
||
|
f(8)
|
||
|
integrate(f, lower = -Inf , upper = Inf)
|
||
|
ibrary(distr6)
|
||
|
d = distr6::Uniform$new(lower = 0 , upper = 7)
|
||
|
#(i)
|
||
|
integrate(d$pdf, lower = -Inf , upper = Inf)
|
||
|
#(ii)
|
||
|
curve(f)
|
||
|
plot(f)
|
||
|
plot(d)
|
||
|
plot(f)
|
||
|
curve(f)
|
||
|
curve(f, from= 0, to= 7)
|
||
|
curve(f, from= -5, to= 10)
|
||
|
curve(f, from= -5, to= 12)
|
||
|
f = function(x)
|
||
|
{
|
||
|
(x>=0 & x <= 7) * 1/7
|
||
|
}
|
||
|
#(i)
|
||
|
integrate(f, lower = -Inf , upper = Inf)
|
||
|
#(ii)
|
||
|
curve(f, from= -5, to= 12)
|
||
|
#(iv)
|
||
|
library(distr6)
|
||
|
d = distr6::Uniform$new(lower = 0 , upper = 7)
|
||
|
d$mgf(t = 1)
|
||
|
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)
|