# Auxiliar 4. # Raimundo Saona Urmeneta. ######### Ejercicio 1 ######### # Definición de parámetros. n <- 100 thetaReal <- 1 cota <- 2 * thetaReal # Generación de variables aleatorias help(rexp) # Chequear qué tipo de parámetro usa. TVector <- rexp(n = 100, rate = thetaReal) XVector <- TVector * (TVector <= cota) + cota * (TVector > cota) # Visualización de la realización XPlot <- XVector * (XVector < cota) + (cota*1.5) * (XVector == cota) hist(x = XPlot, main = "Histograma de la muestra de tiempos") # Estimación k <- sum(TVector <= cota) thetaEst <- sum(XVector)/k # ¿Cuán buena es mi estimación??? ######### Ejercicio 3 ######### # Definir muestra x <- c(0,5,9) # Definir función verosimilitud verosimilitud <- function(theta ){ prob <- 1/pi^3 * 1/ ((x[1]-theta)^2 * (x[2]-theta)^2 * (x[3]-theta)^2) return(prob) } # Plotear thetaPlot <- seq(-3, 10, by = .1) verosimilitudPlot <- verosimilitud(thetaPlot) plot(x = thetaPlot, y = verosimilitudPlot, main = "verosimilitud de theta para x = (0,5,9)") # Re-plotear thetaPlot <- seq(-3, 10, by = .001) verosimilitudPlot <- verosimilitud(thetaPlot) plot(x = thetaPlot, y = verosimilitudPlot, main = "verosimilitud de theta para x = (0,5,9)")