La variable aleatoria continua𝑋representa el número total de horas que una familia usa su aspiradora en un año, medidas en unidades de 100 horas (p. ej.,\(𝑋 = 1.2\) equivale a 120 horas reales). Su función de densidad es:
\[ f(x) = \begin{cases} x, & 0 < x < 1, \\\\ 2 - x, & 1 \le x < 2, \\\\ 0, & \text{en otro caso.} \end{cases} \]
Calcule la probabilidad de que en un periodo de un año una familia utilice su aspiradora:
Comprobación: \(f(x)\) es una función de densidad válida
funcion <- function(x){
ifelse(x > 0 & x < 1, x,
ifelse(x >= 1 & x < 2, 2 - x, 0))}
prob01 <- integrate(funcion, lower = 0, upper = 1)$value
prob12 <- integrate(funcion, lower = 1, upper = 2)$value
prob_total <- integrate(funcion, lower = -Inf, upper = Inf)$value
prob_total
## [1] 1
Menos de 120 horas corresponde a \(X < 1.2\), ya que \(X\) está expresada en centenas de horas.
\[ P(X < 1.2) = \int_{0}^{1} x \,dx + \int_{1}^{1.2} (2-x) \,dx \]
prob_a <- integrate(funcion, lower = 0, upper = 1.2)$value
prob_a
## [1] 0.68
Por lo tanto:
$$
P(X<1.2)=0.68
$$
Entre 50 y 100 horas corresponde al intervalo \(0.5 < X < 1\).
\[ P(0.5 < X < 1) = \int_{0.5}^{1} x \,dx \]
prob_b <- integrate(funcion, lower = 0.5, upper = 1)$value
prob_b
## [1] 0.375
Por lo tanto:
\[ P(0.5<X<1)=0.375 \]
Existe una probabilidad del 37.5% de que la familia utilice la aspiradora entre 50 y 100 horas en el año.
valores_x <- seq(-0.2, 2.2, length.out = 1000)
datos <- data.frame(x = valores_x, fx = funcion(valores_x))
zona_a <- datos %>% filter(x >= 0 & x <= 1.2)
zona_b <- datos %>% filter(x >= 0.5 & x <= 1)
ggplot(datos, aes(x = x, y = fx)) +
geom_line(linewidth = 1, color = "purple") +
geom_area(data = zona_a, aes(x = x, y = fx), fill = "purple", alpha = 0.3) +
geom_area(data = zona_b, aes(x = x, y = fx), fill = "blue", alpha = 0.3) +
labs(
title = "Funcion de densidad f(x)",
x = "X",
y = "f(x)"
) +
theme_minimal(base_size = 12)
La función de distribución acumulada \(F(x)\) se obtiene integrando la densidad desde 0 hasta \(x\):
F_x <- function(x){
ifelse(x <= 0, 0,
ifelse(x < 1, (x^2)/2,
ifelse(x < 2, (-x^2)/2 + 2*x - 1, 1)))
}
datos_F <- data.frame(x = seq(-0.5, 2.5, length.out = 400))
datos_F$Fx <- F_x(datos_F$x)
ggplot(datos_F, aes(x = x, y = Fx)) +
geom_line(color = "blue", size = 1) +
labs(
title = "Función de distribución acumulada F(x)",
x = "X",
y = "F(x)"
) +
theme_minimal(base_size = 12)
La proporción de personas que responden a cierta encuesta enviada por correo es una variable aleatoria continua X que tiene la siguiente función de densidad:
f(x) = (2(x+2))/5, para 0 < x < 1
f(x) = 0, en otro caso
funcion <- function(x){ ifelse(x > 0 & x < 1, (2*(x+2))/5, 0) }
prob_total <- integrate(funcion, lower = 0, upper = 1)$value
prob_total
## [1] 1
El área bajo la curva entre 0 y 1 es igual a 1, por lo tanto la función es una densidad válida.
probabilidad <- integrate(funcion, lower = 1/4, upper = 1/2)$value
probabilidad
## [1] 0.2375
La probabilidad de que más de 1/4 pero menos de 1/2 de las personas respondan a la encuesta es el valor mostrado arriba.
valores_x <- seq(-0.2, 1.2, length.out = 1000)
datos <- data.frame(x = valores_x, fx = funcion(valores_x))
datos_area <- datos %>% filter(x >= 0.25 & x <= 0.5)
ggplot(datos, aes(x = x, y = fx)) +
geom_line(size = 1, color = "purple") +
geom_area(data = datos_area, aes(x = x, y = fx), fill = "purple", alpha = 0.4) +
labs(title = "Densidad f(x) = 2(x+2)/5", x = "x", y = "f(x)") +
theme_minimal()
Integrando la densidad desde 0 hasta x se obtiene:
F(x) = (x² + 4x)/5, para 0 < x < 1
Para x ≤ 0, F(x) = 0 y para x ≥ 1, F(x) = 1
funcion_acumulada <- function(x){
ifelse(x <= 0, 0,
ifelse(x < 1, (x^2 + 4*x)/5, 1))
}
datos_F <- data.frame(x = seq(-0.5, 1.5, length.out = 300)) %>%
mutate(Fx = funcion_acumulada(x))
ggplot(datos_F, aes(x = x, y = Fx)) +
geom_line(color = "blue", size = 1) +
labs(title = "Función de distribución acumulada F(x)", x = "x", y = "F(x)") +
theme_minimal()
Una empresa de inversiones ofrece a sus clientes bonos municipales que vencen despues de varios años. Dado que la función de distribución acumulativa de T, el numero de años para el vencimiento de un bono que se elige al azar, es
\[ F(t) = \begin{cases} 0 & \textit t < 1, \\ \frac {1}{4} & \textit 1 \le t < 3, \\ \frac {1}{2} & \textit 3 \le t < 5, \\ \frac {3}{4} & \textit5 \le t < 7, \\ 1 & \textit t \ge 7 \end{cases} \]
F_t <- function(t){
ifelse(t < 1, 0,
ifelse(t < 3, 1/4,
ifelse(t < 5, 1/2,
ifelse(t < 7, 3/4,
1))))
}
prob_a <- F_t(5) - F_t(4.999999)
cat("a) P(T = 5) =", prob_a, "\n")
## a) P(T = 5) = 0.25
prob_b <- 1 - F_t(3)
cat("b) P(T > 3) =", prob_b, "\n")
## b) P(T > 3) = 0.5
prob_c <- F_t(6) - F_t(1.4)
cat("c) P(1.4 < T < 6) =", prob_c, "\n")
## c) P(1.4 < T < 6) = 0.5
denominador <- 1 - F_t(1.999999)
numerador <- F_t(5) - F_t(1.999999)
prob_d <- numerador / denominador
cat("d) P(T <= 5 | T >= 2) =", prob_d, "\n")
## d) P(T <= 5 | T >= 2) = 0.6666667
library(ggplot2)
t <- c(1, 3, 5, 7)
F_t_vals <- c(1/4, 1/2, 3/4, 1)
df_312 <- data.frame(t = t, F_t = F_t_vals)
df_step_312 <- data.frame(
t = c(0, t),
F_t = c(0, F_t_vals)
)
df_vertical <- data.frame(
t_start = t,
y_start = c(0, F_t_vals[-length(F_t_vals)]),
y_end = F_t_vals
)
ggplot(df_step_312, aes(x = t, y = F_t)) +
geom_segment(data = df_step_312[-nrow(df_step_312),],
aes(x = t, xend = t + c(1, 2, 2, 2),
y = F_t, yend = F_t),
color = "darkblue", linewidth = 1.2) +
geom_segment(data = df_vertical,
aes(x = t_start, xend = t_start, y = y_start, yend = y_end),
linetype = "dotted", color = "darkblue", linewidth = 1.2) +
geom_point(data = df_312, aes(x = t, y = F_t), color = "purple", size = 3) +
geom_point(data = df_vertical, aes(x = t_start, y = y_start),
shape = 1, color = "purple", size = 3) +
scale_x_continuous(breaks = t, limits = c(0, 8)) +
scale_y_continuous(breaks = seq(0, 1, 0.25), limits = c(0, 1.05)) +
labs(title = "Función de Distribución Acumulativa F(t)",
x = "Tiempo (t) en años", y = "F(t)") +
theme_minimal()
t_vals <- c(1, 3, 5, 7)
f_t_vals <- rep(1/4, 4)
df_prob <- data.frame(t = t_vals, f_t = f_t_vals)
ggplot(df_prob, aes(x = factor(t), y = f_t)) +
geom_segment(aes(xend = factor(t), y = 0, yend = f_t), color = "purple", linetype = "dashed", linewidth = 1) +
geom_point(size = 3, color = "purple") +
labs(title = "Función de Probabilidad f(t)",
x = "Tiempo (t) en años",
y = "f(t) = P(T = t)") +
theme_minimal(base_size = 12)
La distribución de probabilidad de \(X\), número de imperfecciones en 10 m de tela, es:
| x | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| p(x) | 0.41 | 0.37 | 0.16 | 0.05 | 0.01 |
x_vals <- 0:4
p_vals <- c(0.41, 0.37, 0.16, 0.05, 0.01)
barplot(height = p_vals, names.arg = x_vals,
xlab = "x", ylab = "p(x)", main = "Función de probabilidad p(x)")
$$
F(x)=
\[\begin{cases} 0, & x<0,\\ 0.41, & 0\le x<1,\\ 0.78, & 1\le x<2,\\ 0.94, & 2\le x<3,\\ 0.99, & 3\le x<4,\\ 1, & x\ge 4. \end{cases}\]$$
F_step <- function(x){
ifelse(x < 0, 0,
ifelse(x < 1, 0.41,
ifelse(x < 2, 0.78,
ifelse(x < 3, 0.94,
ifelse(x < 4, 0.99, 1)))))
}
xs <- seq(-0.5, 4.5, by = 0.01)
plot(xs, F_step(xs), type = "s", xlab = "x", ylab = "F(x)",
main = "Función de distribución acumulativa F(x)")
abline(h = c(0,1), lty = 3); abline(v = 0:4, lty = 3)
Sea la función de densidad \[ f(x)=\begin{cases} k\sqrt{x}, & 0<x<1,\\ 0, & \text{en otro caso}. \end{cases} \] Pida: (a) evaluar \(k\). (b) calcular \(F(x)\) y usarlo para evaluar \(P(0.3<X<0.6)\). (c) graficar \(f(x)\) y \(F(x)\).
\[ \int_0^1 k\sqrt{x}\,dx=1 \;\Rightarrow\; k=\tfrac{3}{2}. \]
\[ F(x)=\begin{cases} 0, & x\le 0,\\ x^{3/2}, & 0<x<1,\\ 1, & x\ge 1. \end{cases} \]
\[ P(0.3<X<0.6)=F(0.6)-F(0.3)=0.6^{3/2}-0.3^{3/2}. \]
Valor numérico: 0.300441
f <- function(x) ifelse(x>0 & x<1, (3/2)*sqrt(x), 0)
xs <- seq(-0.2, 1.2, by = 0.001)
plot(xs, f(xs), type = "l", xlab = "x", ylab = "f(x)",
main = "Densidad f(x) = (3/2)√x en (0,1)")
abline(h = 0, lty = 3); abline(v = c(0,1), lty = 3)
F <- function(x){
ifelse(x <= 0, 0,
ifelse(x < 1, x^(3/2), 1))
}
plot(xs, F(xs), type = "l", xlab = "x", ylab = "F(x)",
main = "Función de distribución F(x)")
abline(h = c(0,1), lty = 3); abline(v = c(0,1), lty = 3)
El tiempo que pasa, en horas, antes de que una parte importante de un equipo electrónico falle tiene la siguiente función de densidad:
\[ f(x) = \begin{cases} \frac{1}{2000} e^{-x/2000}, & x \ge 0 \\ 0, & x < 0 \end{cases} \]
Sabemos que:
\[ F(x) = \int_0^x f(t) dt = \int_0^x \frac{1}{2000} e^{-t/2000} dt \]
\[ F(x) = 1 - e^{-x/2000}, \quad x \ge 0 \]
F.x <- function(x){
ifelse(x < 0, 0, 1 - exp(-x/2000))
}
valores_x <- seq(0, 10000, by = 100)
df <- data.frame(x = valores_x, Fx = F.x(valores_x))
ggplot(df, aes(x, Fx)) +
geom_line(color = "purple", linewidth = 1) +
labs(title = "Función de distribución acumulada F(x)",
x = "x (horas)",
y = "F(x)") +
theme_minimal()