set.seed(123)  # Đặt seed để kết quả có thể tái lập
sample_data <- rpois(200, lambda = 4)
mean_value <- mean(sample_data)
variance_value <- var(sample_data)
cat("Giá trị trung bình:", mean_value, "\n")
## Giá trị trung bình: 4.095
cat("Phương sai:", variance_value, "\n")
## Phương sai: 3.614045
# Vẽ QQ-plot
qqplot(qpois(ppoints(200), lambda = 4), sample_data, 
       main = "QQ-plot for Poisson Distribution",
       xlab = "Theoretical Quantiles", 
       ylab = "Sample Quantiles")
abline(0, 1, col = "red")  # Đường y = x để so sánh

data(iris)
quantiles <- apply(iris[, 1:4], 2, quantile, probs = c(0.25, 0.75))
print("Khoảng giá trị từ 25% đến 75%:")
## [1] "Khoảng giá trị từ 25% đến 75%:"
print(quantiles)
##     Sepal.Length Sepal.Width Petal.Length Petal.Width
## 25%          5.1         2.8          1.6         0.3
## 75%          6.4         3.3          5.1         1.8
hist(iris$Petal.Length, 
     main = "Biểu đồ histogram của chiều dài cánh hoa", 
     xlab = "Chiều dài cánh hoa (cm)", 
     col = "lightblue", 
     border = "black", 
     breaks = 20)