푸아송과 이항에서 시뮬레이션하기
각 동전이 앞면이 나올 확률이 0.2%인 동전 100,000개를 던진다고 가정하면, 이를 Poisson(2) 분포로 근사할 수 있습니다. 시뮬레이션으로 확인해 보세요.
이 연습은 강의의 일부입니다
R로 배우는 확률 기초
연습 안내
- Binomial(1000, .002) 분포에서 100,000번 추출하세요. 결과를
binom_sample로 저장하세요. - 이 이항분포를 근사하는 푸아송 분포에서
rpois()함수를 사용해 100,000번 추출하세요. 결과를poisson_sample로 저장하세요. compare_histograms()함수로 두 분포를 비교하세요. (인자가 두 개, 즉 비교할 두 샘플이라는 점을 기억하세요).
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Draw a random sample of 100,000 from the Binomial(1000, .002) distribution
binom_sample <-
# Draw a random sample of 100,000 from the Poisson approximation
poisson_sample <-
# Compare the two distributions with the compare_histograms function