Empirical Distribution 본문
1. Generate 100 observations from a N (0, 1) distribution.
Compute the empirical CDF F. Plot the true CDF and the empirical CDF.
#F
par(mfrow = c(1,2))
x <- seq(-3,3,length = 100) #-3부터 3까지 100개의 독립변수 생성
F <- pnorm(x) #독립변수를 정규분포의 pdf에 넣겠다
plot(x, F, xlab = "x", ylab = "F", sub = "True cdf")
#F_hat
n <- 100
x_star <- rnorm(n, 0, 1) #표준정규분포에서 난수를 뽑겠다
x_star <- sort(x_star) #뽑은 난수를 정렬
F_hat <- (1:n)/n
plot(x_star, F_hat, xlab = "x_star", ylab = "Fn", sub = "F hat")
par(mfrow = c(1,1))
plot(x, F)
lines(x_star, F_hat)
'Applied > Statistical Computing' 카테고리의 다른 글
Chapter 14 - 0 ) Optimization Introduction (0) | 2022.11.17 |
---|---|
Bootstrap estimate of bias (0) | 2022.11.13 |
Chapter 13- 2,3) Gaussian Quadrature and Laplace Approximation (0) | 2022.11.10 |
Chapter 13 - 1) Numerical Methods - Newton (0) | 2022.11.10 |
Chapter 12 - 1) Probability Density Estimation (0) | 2022.11.08 |
Comments