Sean X, Y variables aleatorias continuas con función de densidad de probabilidad conjunta \(f_{X,Y} (x, y)\) definida por
\[ f_{X,Y}(x,y) = \begin{cases} 6 x y & \text{si } 0 \leq x \leq 1, 0 \leq y \leq \sqrt{x} \\ 0 & \text{en otra parte} \end{cases} \] 1) Con ayuda del software R, realice una representación tridimensional de la función \(f_{XY} (x, y)\)
fn <- function(x,y){
if (x >= 0 && x<=1 && y>=0 && y<= sqrt(x))
{
return (6*x*y)
}
else
{
return(0)
}
}
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.3.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
x <- seq(0, 1, length = 50) # Crear la secuencia de valores para x e y
y <- seq(0, 1, length = 50)
z <- outer(x, y, Vectorize(fn)) # Crear una matriz para almacenar los valores de z = f(x, y)
plot_ly(x = ~x, y = ~y, z = ~z, type = "surface") %>% # Graficar la función con plotly
layout(scene = list(
xaxis = list(title = "x"),
yaxis = list(title = "y"),
zaxis = list(title = "f(x, y)")
))
2) Con ayuda del software R, realice una representación bidimensional de la región acotada \(0\leq x\leq 1,0\leq y \leq \sqrt{x}\)
x <- seq(0, 1, length = 100)
y <- sqrt(x)
plot(x, y, type = "l", lwd = 2, col = "blue",
xlab = "x", ylab = "y",
main = "Región acotada por 0 ≤ x ≤ 1 y 0 ≤ y ≤ √x")
# Rellenar el área bajo la curva
polygon(c(0, x, 1), c(0, y, 0), col = "lightblue", border = NA)
3) Halle las funciones de densidad marginal \(f_X(x)\) y \(f_Y(y)\)
$$ \[\begin{align} f_{X,Y}(x,y) &= \int_0^1\int_{y^2}^16xydxdy = \int_0^1\int_0^{\sqrt{x}}6xydydx\\ f_X(x) &= \int_0^{\sqrt{x}}6xydy = \frac{6xy^2}{2} \Big|_0^{\sqrt{x}} = 3x(\sqrt{x})^2 = 3x^2\\ f_Y(y) &= \int_{y^2}^16xydx = 6y \frac{x^2}{2}\Big|_{y^2}^1 = 3y-3y^5=3y(1-y^4) \end{align}\]
$$
4) Halle la función condicional de X dada Y, es decir, \(f_{X|Y}(x|y)\)
\[ f_{X|Y}(X|Y) = \frac{f_{X,Y}(x,y)}{f_Y(y)} = \frac{6xy}{3y(1-y^4)} = \frac{2x}{1-y^4} \]
5) Halle la \(P(Y > X)\). Gráfica la región bidimensional que representa la probabilidad solicitada
# Configuración del gráfico
plot(0, 0, xlim=c(0, 1), ylim=c(0, 1), type="n", xlab="x", ylab="y", main="Región donde Y > X y Y <= sqrt(X)")
# Curva de y = sqrt(x)
curve(sqrt(x), from=0, to=1, add=TRUE, col="#CD8C95", lwd=2)
# Línea de y = x
abline(a=0, b=1, col="#CD8C95", lwd=2)
# Sombrear solo la región donde y > x y y <= sqrt(x)
x <- seq(0, 1, length=100)
polygon(c(x, rev(x)),
c(sqrt(x), rev(x)),
col="#CD8C95", border=NA)
\[ \begin{align} P(Y>X) = 1-P(Y<X) & = 1 - \int_0^1\int_0^x 6xy \ dydx \\ & = 1 - \int_0^1\int_0^x 6xy \ dydx \\ & = 1- \int_0^1 6x \ \ \ \frac{y^2}{2} \Big|_0^x \ dx \\ & = 1- \int_0^1 6x \ \ \ \frac{x^2}{2} \ dx \\ & = 1- \int_0^1 3x^3 \ dx \\ & = 1- \ \ \frac{3x^4}{4} \Big|_0^1 \\ & = 1- \frac{3}{4} = \frac{1}{4} = 0.25 \\ \\ \\ & P(Y>X)= \frac{1}{4} \end{align} \]
6) Halle la función que representa el valor esperado de X dado Y, \(E(X|Y = y)\)
\[ \begin{align} E(X|Y = y) & = \int_0^1 x \frac{2x}{1-y^4} dx\\ & = \int_0^1 \frac{2x^2}{1-y^4} dx\\ & = \frac{2}{1-y^4} \int_0^1 x^2 dx \\ & = \frac{2}{1-y^4} \ \ \frac{x^3}{3} \Big|_0^1\\ & = \frac{2}{1-y^4} \ \ \frac{1}{3} = \frac{2}{3(1-y^4)} \\ \\ &E(X|Y = y) = \frac{2}{3(1-y^4)} \end{align} \] Calculo de \(E(X^2|Y = y)\) Para la varianza
\[ \begin{align} E(X|Y = y) & = \int_0^1 x^2 \frac{2x}{1-y^4} dx\\ & = \int_0^1 \frac{2x^3}{1-y^4} dx\\ & = \frac{2}{1-y^4} \int_0^1 x^3 dx \\ & = \frac{2}{1-y^4} \ \ \frac{x^4}{4} \Big|_0^1\\ & = \frac{2}{1-y^4} \ \ \frac{1}{4} = \frac{2}{4(1-y^4)} = \frac{1}{2(1-y^4)} \\ \\ &E(X^2|Y = y) = \frac{1}{2(1-y^4)} \end{align} \]
7) Halle la función que representa la varianza de X dado Y, \(Var(X|Y = y)\)
\[ \begin{align} Var(X|Y = y) & = \frac{1}{2\left(1 - y^4\right)} - \left( \frac{2}{3(1 - y^4)} \right) ^2 \\ \\ Var(X|Y = y) & = \frac{1}{2\left(1 - y^4\right)} - \frac{4}{9\left(1 - y^4\right)^2} \end{align} \]/