ejercicio 90

ejer90 = rnorm(1000, mean = 20, sd=2)
hist(ejer90)

mean(ejer90)
## [1] 19.9343
var(ejer90)
## [1] 4.028138

ejercicio 91

x91 = rnorm(5000, mean = 10, sd = sqrt (2))
y91 = rnorm(5000, mean = 15, sd = sqrt (3))
mean(x91)
## [1] 9.995768
mean(y91)
## [1] 14.96774
z91 = x91 + y91
mean(z91)
## [1] 24.96351
var(z91)
## [1] 4.893778
var(x91)
## [1] 1.961036
var(y91)
## [1] 2.960041
x91 = rnorm(1000, mean = 10, sd = sqrt (2))
y91 = rnorm(1000, mean = 15, sd = sqrt (3))
mean(x91)
## [1] 10.0533
mean(y91)
## [1] 14.99687
z91 = x91 + y91
mean(z91)
## [1] 25.05017
var(z91)
## [1] 5.005603
var(x91)
## [1] 1.973692
var(y91)
## [1] 3.018416
x91 = rnorm(100, mean = 10, sd = sqrt (2))
y91 = rnorm(100, mean = 15, sd = sqrt (3))
mean(x91)
## [1] 10.03358
mean(y91)
## [1] 14.97286
z91 = x91 + y91
mean(z91)
## [1] 25.00644
var(z91)
## [1] 6.101815
var(x91)
## [1] 1.887154
var(y91)
## [1] 3.825992

ejercicio 92

x92 = rnorm(100, mean = 10, sd = sqrt (2))
y92 = rnorm(100, mean = 15, sd = sqrt (3))
mean(x92)
## [1] 9.85109
mean(y92)
## [1] 14.91388
var(x92)
## [1] 2.062219
var(y92)
## [1] 3.6886
z92 = x92 * y92
mean(z92)
## [1] 146.625
var(z92)
## [1] 734.5434
x92 = rnorm(1000, mean = 10, sd = sqrt (2))
y92 = rnorm(1000, mean = 15, sd = sqrt (3))
mean(x92)
## [1] 9.999838
mean(y92)
## [1] 14.98236
var(x92)
## [1] 2.112817
var(y92)
## [1] 2.737891
z92 = x92 * y92
mean(z92)
## [1] 149.8232
var(z92)
## [1] 762.6962
x92 = rnorm(5000, mean = 10, sd = sqrt (2))
y92 = rnorm(5000, mean = 15, sd = sqrt (3))
mean(x92)
## [1] 10.05148
mean(y92)
## [1] 14.97529
var(x92)
## [1] 1.964941
var(y92)
## [1] 2.96889
z92 = x92 * y92
mean(z92)
## [1] 150.515
var(z92)
## [1] 742.4318

ejercicio 93

x93 = rnorm(100, mean = 0, sd = sqrt (4))
y93 = x93 * x93
mean(x93)
## [1] 0.2584308
var(x93)
## [1] 4.286907
mean(y93)
## [1] 4.310824
var(y93)
## [1] 33.30386
hist(y93)

hist(x93)

ejercicio 95

inter95 <- data.frame(time95=c(1, 2, 3, 4, 6, 7, 8, 10, 11, 12),
                 temp95=c(10, 12, 18, 24, 21, 20, 18, 15, 13, 8))
plot(inter95$time95, inter95$temp95, col='blue', pch=19)

model <- lm(temp95 ~ time95, data = inter95)
temp95_new = approx(inter95$time95, inter95$temp95, xout=5)
temp95_new
## $x
## [1] 5
## 
## $y
## [1] 22.5
temp95_new1 = approx(inter95$time95, inter95$temp95, xout=9)
temp95_new1
## $x
## [1] 9
## 
## $y
## [1] 16.5

ejercicio 96

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
ejer96a <- data.frame(hour=1:5, temp96a = c(15, NA, 14, 15, 18))
ejer96a
ejer96a <- ejer96a %>% mutate( temp96a = na.approx(temp96a))
ejer96a
ejer96b <- data.frame(hour=1:5, temp96b = c(16, 11, NA, 15, 20))
ejer96b
ejer96b <- ejer96b %>% mutate( temp96b = na.approx(temp96b))
ejer96b

ejercicio 97

x97=c(0, 0.25, 0.75, 1.25, 1.5, 1.75, 1.875, 2, 2.125, 2.25)
y97=c(1.2, 1.18, 1.1, 1, 0.92, 0.8, 0.7, 0.55, 0.35, 0)
ejer97 <- data.frame(x97, y97)
plot(ejer97)
lines(spline(x97, y97))

# ejercicio 98

time98 = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
temp98 = c(72.5, 78.1, 86.4, 92.3, 110.6, 111.5, 109.3, 110.2, 110.5, 109.9, 110.2)
ejer98 <- data.frame(time98, temp98)
plot(ejer98)

plot(ejer98, type = "o", col = "blue")
lines(spline(time98, temp98,), col = "red")

ejer98b <- lm(temp98 ~ time98, data = ejer98)
temp98_1 = approx(ejer98$time98, ejer98$temp98, xout = 0.6)
temp98_1
## $x
## [1] 0.6
## 
## $y
## [1] 75.86
temp98_2 = approx(ejer98$time98, ejer98$temp98, xout = 2.5)
temp98_2
## $x
## [1] 2.5
## 
## $y
## [1] 89.35
temp98_3 = approx(ejer98$time98, ejer98$temp98, xout = 4.7)
temp98_3
## $x
## [1] 4.7
## 
## $y
## [1] 111.23
temp98_4 = approx(ejer98$time98, ejer98$temp98, xout = 8.9)
temp98_4
## $x
## [1] 8.9
## 
## $y
## [1] 109.96
temp98_1b = spline (temp98, y = NULL, n= 3*length(temp98), 
        method = "fmm", xmin = min(temp98), xmax = max(temp98), 
        xout = 0.6, ties = mean)
temp98_1b
## $x
## [1] 0.6
## 
## $y
## [1] 72.71518
temp98_2b = spline (temp98, y = NULL, n= 3*length(temp98), 
                    method = "fmm", xmin = min(temp98), xmax = max(temp98), 
                    xout = 2.5, ties = mean)
temp98_2b
## $x
## [1] 2.5
## 
## $y
## [1] 82.72838
temp98_3b = spline (temp98, y = NULL, n= 3*length(temp98), 
                    method = "fmm", xmin = min(temp98), xmax = max(temp98), 
                    xout = 4.7, ties = mean)
temp98_3b
## $x
## [1] 4.7
## 
## $y
## [1] 105.7781
temp98_4b = spline (temp98, y = NULL, n= 3*length(temp98), 
                    method = "fmm", xmin = min(temp98), xmax = max(temp98), 
                    xout = 8.9, ties = mean)
temp98_4b
## $x
## [1] 8.9
## 
## $y
## [1] 110.5312

ejercicio 99

xpos <- 5
timei99 <- 2
timef99 <- 10
resultado <- integrate(function(t) ( 5+(7*(t^2)) ), lower = timei99, upper = timef99)
pos99 <- resultado$value + 5
pos99
## [1] 2359.667

ejercicio 100

time100 = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
flow100 = c(0, 80, 130, 150, 150, 160, 165, 170, 160 ,140, 120)
ejer100 = data.frame(time100, flow100)
plot (ejer100)

modelo <- lm(ejer100$flow100 ~ poly(time100, degree = 4, raw = TRUE, simple = TRUE), data = ejer100)
summary(modelo)
## 
## Call:
## lm(formula = ejer100$flow100 ~ poly(time100, degree = 4, raw = TRUE, 
##     simple = TRUE), data = ejer100)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.6457 -1.1888  0.0466  2.5583  6.5967 
## 
## Coefficients:
##                                                        Estimate Std. Error
## (Intercept)                                             0.55944    5.43012
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)1 103.31197    8.36290
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)2 -25.69930    3.66354
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)3   2.93512    0.56376
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)4  -0.12821    0.02796
##                                                       t value Pr(>|t|)    
## (Intercept)                                             0.103 0.921300    
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)1  12.354 1.72e-05 ***
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)2  -7.015 0.000419 ***
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)3   5.206 0.002003 ** 
## poly(time100, degree = 4, raw = TRUE, simple = TRUE)4  -4.586 0.003747 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.673 on 6 degrees of freedom
## Multiple R-squared:  0.9923, Adjusted R-squared:  0.9871 
## F-statistic: 192.9 on 4 and 6 DF,  p-value: 1.828e-06
# flujo = 0.559 + 103.31t - 25.699t^2 + 2.935 t^3 - 0.128 t^4
vol100 <- integrate(function(t) (0.559 + 103.31*t - 25.699*t^2 + 2.935*t^3 - 0.128*t^4), lower = 0, upper = 10)
altura_a_10min= vol100$value/100
altura_a_10min
## [1] 13.82257

ejercicio 101

library(mosaicCalc)
## Warning: package 'mosaicCalc' was built under R version 4.2.3
## Loading required package: mosaic
## Warning: package 'mosaic' was built under R version 4.2.3
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
## Warning: package 'mosaicCore' was built under R version 4.2.3
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
fun = antiD( 5*x^2-6*x+8 ~ x )
fun
## function (x, C = 0) 
## (5 * x^3 - 9 * x^2 + 24 * x)/3 + C

ejercicio 102

x102=c(0:10)
y102=c(0, 2, 5, 7, 9, 12, 15, 18, 22, 20, 17)
ejer102 <- data.frame(x102, y102)
plot(ejer102)
lines(spline(x102, y102))