f = function(x) { if( (0 <= x) & (x<= 7) ) { return(1/7) } else { return(0) } } f(10) f(6) 1/7 integrate(f) f integrate(f) integrate(0) integrate(1/7) f integrate(f) integrate(f, lower = inf) integrate(f, lower = infinte) infinite inf infy infty Inf integrate(f, lower = Inf) integrate(f, lower = Inf, upper = Inf) f = function(x) { if( (0 >= x) & (x<= 7) ) { return(1/7) } else { return(0) } } integrate(f, lower = Inf, upper = Inf) f = function(x) { if( (0 >= x) & (x<= 7) ) { return(1/7) } else { return(0) } } integrate(f, lower = Inf, upper = Inf) f = function(x) { if( (x >= 0) & (x<= 7) ) { return(1/7) } else { return(0) } } integrate(f, lower = Inf, upper = Inf) f = function(x) { if( (x >= 0) & (x<= 7) ) { return(1/7) } else { return(0) } } integrate(f) f = function(x) { (x<0)*0 + (x>=0 & x<=7) * (1/7) + (x>7)*0 } integrate(f, lower = Inf, upper = Inf) f = function(x) { if( (x >= 0) & (x<= 7) ) { 1/7 } else { 0 } } #f = function(x) #{ # (x<0)*0 + (x>=0 & x<=7) * (1/7) + (x>7)*0 #} integrate(f, lower = Inf, upper = Inf) f = function(x) { (x<0)*0 + (x>=0 & x<=7) * (1/7) + (x>7)*0 } integrate(f) f = function(x) { (x<0)*0 + (x>=0 & x<=7) * (1/7) + (x>7)*0 } integrate(f, lower = Inf, upper = Inf) f plot(f) library(distr6) install.packages(distr6) install.packages("distr6") library(distr6) ?distr6::kthmoment() distr6::kthmoment(f, 1) library(distr6) f = function(x) { (x<0)*0 + (x>=0 & x<=7) * (1/7) + (x>7)*0 } integrate(f, lower = Inf, upper = Inf) plot(f) distr6::kthmoment(f, 1) distr6::mgf(f,1) library(distr6) f = function(x) { (x<0)*0 + (x>=0 & x<=7) * (1/7) + (x>7)*0 } integrate(f, lower = Inf, upper = Inf) plot(f) distr6::mgf(f) ?mgf distr6::mgf(f,1) mfg(1) mgf(1) mean(f) integrate(f, lower = Inf, upper = Inf) x1 = c(12,11,8,14,10) x2 = c(10,8,5,11,7) x3= c(8,11,11,13,6) x1 = c(12,11,8,14,10) x2 = c(10,8,5,11,7) x3= c(8,11,11,13,6) mean(x1) ?distr6::Uniform ?distr6::Uniform$new(lower = 0 , upper = 1/7) distr6::Uniform$new(lower = 0 , upper = 1) ok = distr6::Uniform$new(lower = 0 , upper = 1/7) ok$mgf() ok$mgf ok plot(ok) ?dunif ok = distr6::Uniform$new(f, lower = 0 , upper = 1/7) ?distr6::Distribution lenght(1) length(1) length(3) ok = distr6::Uniform$new(f, lower = 0 , upper = 1/7) ?distr6::Uniform$new() ?distr6::Uniform distr6::Uniform$new(lower = 0 , upper = 1/7) ok plot(ok) ok$mgf ok$mgf(t = 1) distr6::Uniform$new(lower = 0 , upper = 7) d = distr6::Uniform$new(lower = 0 , upper = 7) plot(d) d$mean() d = distr6::Uniform$new(lower = 0 , upper = 7) integrate(d) d d$pdf() d$print() d$summary() d$mgf(1) d = distr6::Uniform$new(lower = 0 , upper = 7) plot(d) d$mgf(t = 1) integrate(d) d$cdf() d$cdf d$pdf integrate(d$pdf) integrate(d$pdf, lower = 0 , upper = 7) integrate(d$pdf, lower = -Inf , upper = Inf) d$mgf(t = 1) as.matrix(x1,x2,x3) x2 x3 as.matrix(x1,x2,x3) x1 x1 = c(12,11,8,14,10) x2 = c(10,8,5,11,7) x3= c(8,11,11,13,6) as.matrix(x1,x2,x3) matrix(x1,x2,x3) x1 = c(12,11,8,14,10) x2 = c(10,8,5,11,7) x3= c(8,11,11,13,6) matrix(x1,x2,x3) ?matrix ?as.matrix c(x1,x2,x3) as.matrix(c(x1,x2,x3)) as.matrix(c(x1,x2,x3), nrow(3)) as.matrix(c(x1,x2,x3), nrow= 3) matrix(c(x1,x2,x3), nrow= 3) matrix(c(x1,x2,x3), nrow= 4) matrix(c(x1,x2,x3), nrow= 4) matrix(c(x1,x2,x3), ncol = 4) matrix(c(x1,x2,x3), ncol = 3) x1 = c(12,11,8,14,10) x2 = c(10,8,5,11,7) x3= c(8,11,11,13,6) matrix(c(x1,x2,x3), ncol = 3) 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) m Matrix::mean(m) cov(m) cov(m) mean(m) cov(x1,x2,x3) mean(x1) 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_mean = c(mean(x1), mean(x2), mean(x3)) cov(m) 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_mean = c(mean(x1), mean(x2), mean(x3)) cov(m) vector_mean 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)) cov(m) 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) plot(d) library(distr6) d = distr6::Uniform$new(lower = 0 , upper = 7) #(i) integrate(d$pdf, lower = -Inf , upper = Inf) #(ii) plot(d) curve(d) curve(d) #(ii) plot(d) ?curve() curve(d,from = 0, to=7) curve(plot(d),from = 0, to=7) curve(from = 0, to=7) #(ii) curve(d) plot(d) curve(d$pdf) plot(d$pdf) plot(d$cdf()) plot(d$cdf ) plot(d) curve(d) curve(distr6::Uniform$new(lower = 0 , upper = 7)) curve(distr6::Uniform$new(lower = 0 , upper = 7)) curve(d(x)) d$print() d$print d$summary() curve(d$summary()) plot(d, type='l') plot(d) plot(d)[1] curve(d) d d$cdf() d$cdf d$pdf curve(d$pdf) curve(d$pdf(x)) curve(d(x)) #(i) integrate(d$pdf, lower = -Inf , upper = Inf)