set.seed(123)
#Conductividad electrica
CE = rnorm(n = 40,
mean = 1.5,
sd = 0.2)
hist(CE)
abline(v = mean(CE), col = "red", lwd = 5)
text(x = mean(CE), y = 7,"media",cex = 2,col = "red")
abline(v = mean(CE)+sd(CE), col = "green", lwd = 5)
text(x = mean(CE)+0.3, y = 7,"media+sd",cex = 2,col = "darkgreen")
abline(v = mean(CE)-sd(CE), col = "green", lwd = 5)
text(x = mean(CE)-0.3, y = 7,"media-sd",cex = 2,col = "darkgreen")

library(psych)
describe(CE)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 40 1.51 0.18 1.52 1.51 0.19 1.11 1.86 0.75 -0.07 -0.57 0.03
REvisar que son coordenadas varicentica. utilidad en agronomia.
relacion con datos composicionales.
set.seed(123)
CE2 = runif(n = 400,min = 1.2,max = 1.5)
hist(CE2,breaks = 10)
abline(v = mean(CE2), col = "red", lwd = 5)
text(x = mean(CE2), y = 7,"media",cex = 2,col = "red")

describe(CE2)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 400 1.35 0.09 1.34 1.35 0.11 1.2 1.5 0.3 0.09 -1.18 0
Simul <- replicate(n = 100,
expr = runif(n = 5,min = 1.2,max = 1.5))
dim(Simul)
## [1] 5 100
Medias = colMeans(Simul)
length(Medias)
## [1] 100
hist(Medias)

set.seed(123)
estado = round(runif( n = 50 , min = 0,max = 0.6),0)
table(estado)
## estado
## 0 1
## 39 11
prop = mean(estado)
hist(estado)

sim2 = replicate(n = 20000,
expr = round(runif( n = 200 ,
min = 0,max = 0.6),0))
dim(sim2)
## [1] 200 20000
medias2 = colMeans(sim2)
hist(medias2)
