원본 : 결합 밀도함수 문제 질문 - 통계 마이너 갤러리 (dcinside.com)


R코드 : 코파일럿 결과

#F(x,y)시각화

library(ggplot2)

library(dplyr)


# Define the function

f <- function(x, y) {

  ifelse(x <= 0 | y <= 0, 0,

         ifelse(0 < x & x < y & y < 1, x^2 * (2*y^2 - x^2),

                ifelse(0 < x & x < 1, x^2 * (2 - x^2),

                       ifelse(y >= 1, y^4,

                              ifelse(0 < y & y < min(x, 1), 1,

                                     ifelse(x >= 1 & y >= 1, 1, NA))))))

}


# Create a data frame of x and y values

df <- expand.grid(x = seq(-1, 2, 0.01), y = seq(-1, 2, 0.01))


# Compute the function values

df <- df %>%

  mutate(z = mapply(f, x, y))


# Plot the function

ggplot(df, aes(x = x, y = y, fill = z)) +

  geom_tile() +

  scale_fill_gradientn(colors = rainbow(5)) +

  theme_minimal() +

  labs(x = "X", y = "Y", fill = "F(x, y)",

       title = "Visualization of the function F(x, y)")




a04424ad2c06782ab47e5a67ee91766dc28ff1ecd4acc7cfbf10dbc253d5d7211c36ed430207ccd32b7809c02c46