\[x_{hi} = F^{-1} ( x ), \text{ onde } x = \frac{i - Rand_i}{n}\]
\[x_{di} = F^{-1} ( x ), \text{ onde }x = \frac{i - 0.5}{n}\]
Função de Densidade: \(f(x) = 2x\) onde \(0 \leq x \leq 1\)
Função de Distribuição: \(F(x) = x^2 >> x = \sqrt u\)
Número aleatório: \(F^{-1}(u) = x >> x = \sqrt u\)
Em runif:
n = 100
x <- sqrt(runif(n))
hist(x)
Em hipercubo latino:
HL<- rep(0,n)
for(i in 1:n){
y <- sqrt((i-runif(1)/n))
HL[i] <- y
}
hist(HL)
Em amostragem descritiva:
AD <- rep(0,n)
for(i in 1:n){
y <- sqrt((i-0.5/n))
AD[i] <- y
}
hist(AD)
Função de Densidade: \(f(x) = 2x\) onde \(0 \leq x \leq 1\)
Função de Distribuição: \(F(x) = x^2 >> x = \sqrt u\)
Número aleatório: \(F^{-1}(u) = x >> x = \sqrt u\)
Em runif:
n = 100
x <- sqrt(runif(n))
hist(x)
Em hipercubo latino:
HL<- c()
for(i in 1:n){
y <- sqrt((i-runif(1)/n))
HL[i] <- y
}
hist(HL)
Em amostragem descritiva:
AD <- c()
for(i in 1:n){
y <- sqrt((i-0.5/n))
AD[i] <- y
}
hist(AD)
Função de Densidade: \(f(x) = \lambda .\exp{(-\lambda.x)}\)
Função de Distribuição: \(F(x) = 1 - \exp{(-\lambda.x)}\)
Número aleatório: \(F^{-1}(u) = x >> - \log(u)/\lambda\)
Em runif:
n = 100
lambda = 1
u = runif(n)
x <- -log(runif(n))/lambda
hist(x)
Em hipercubo latino:
HL <- c()
i = 1
for(i in 1:n){
y = -log((i - runif(1))/n)/lambda
HL[i] <- y
}
hist(HL)
Em amostragem descritiva:
AD <- c()
lambda <- 1
for(i in 1:n){
y <- -log((i - 0.5)/n)/lambda
AD[i] <- y
}
hist(AD)
ks.test(x,pexp,1)
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: x
## D = 0.084022, p-value = 0.4803
## alternative hypothesis: two-sided
ks.test(HL,pexp,1)
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: HL
## D = 0.0098566, p-value = 1
## alternative hypothesis: two-sided
ks.test(AD,pexp,1)
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: AD
## D = 0.005, p-value = 1
## alternative hypothesis: two-sided
install.packages("lhs")
require(lhs)
Função: ´randomLHS(n,k)´
x <- randomLHS(1000,1)
y <- qnorm(x) # Normal
hist(y,freq = F)
curve(dnorm(x),add = T,-3,3)
x <- randomLHS(1000,1)
y <- qexp(x) #Exponencial
hist(y,freq = F)
curve(dexp(x),add = T)
x <- randomLHS(1000,1)
y <- qlogis(x) #Logística
hist(y,freq = F)
curve(dlogis(x),add = T)