R에서의 표본추출
Richie Cotton
Data Evangelist at DataCamp
{adjective} 방법이나 의식적인 결정 없이 만들어지거나, 이루어지거나, 선택된 것.
random 패키지로 사용 가능.seed <- 1
calc_next_random(seed)
3
calc_next_random(3)
2
calc_next_random(2)
6
| function | distribution | function | distribution | function | distribution |
|---|---|---|---|---|---|
| rbeta | 베타 | rgeom | 기하 | rsignrank | 윌콕슨 부호순위 |
| rbinom | 이항 | rhyper | 초기하 | rt | t |
| rcauchy | 코시 | rlnorm | 로그정규 | runif | 균등 |
| rchisq | 카이제곱 | rlogis | 로지스틱 | rweibull | 와이블 |
| rexp | 지수 | rnbinom | 음이항 | rwilcox | 윌콕슨 순위합 |
| rf | F | rnorm | 정규 | ||
| rgamma | 감마 | rpois | 포아송 |
rbeta(5000, shape1 = 2, shape2 = 2)
[1] 0.2788 0.7495 0.6485 0.6665 0.6546 0.1575
...
[4996] 0.84719 0.35177 0.92796 0.67603 0.53960
randoms <- data.frame(
beta = rbeta(5000, shape1 = 2, shape2 = 2)
)
ggplot(randoms, aes(beta)) +
geom_histogram(binwidth = 0.1)

set.seed(20000229)
rnorm(5)
-1.6538 -0.4028 -0.1654 -0.0734 0.5171
rnorm(5)
1.908 0.379 -1.499 1.625 0.693
set.seed(20000229)
rnorm(5)
-1.6538 -0.4028 -0.1654 -0.0734 0.5171
rnorm(5)
1.908 0.379 -1.499 1.625 0.693
set.seed(20000229)
rnorm(5)
-1.6538 -0.4028 -0.1654 -0.0734 0.5171
rnorm(5)
1.908 0.379 -1.499 1.625 0.693
set.seed(20041004)
rnorm(5)
-0.6547 -0.7854 -0.0152 0.1514 0.5285
rnorm(5)
0.748 0.974 0.174 -0.781 -0.930
R에서의 표본추출