본문으로 건너뛰기
🛠️ToolsShed

표본 크기 계산기

설문조사 및 연구에 필요한 표본 크기를 계산합니다.

이 도구 소개

표본 크기 계산기는 결과를 신뢰할 수 있으려면 몇 명의 응답자가 필요한지 알려줍니다. 응답을 너무 적게 모으면 통계적으로 신뢰할 수 없고, 너무 많이 모으면 시간과 예산을 낭비하게 되는 흔한 조사 문제를 해결해 줍니다.

사용하려면 원하는 신뢰 수준, 허용 가능한 오차 범위, 전체 모집단 크기, 예상 응답 분포를 설정하면 필요한 표본 크기가 산출됩니다. 시장 조사, 학술 연구, A/B 테스트 계획, 여론 조사에 유용합니다.

신뢰 수준을 높이거나 오차 범위를 줄이면 항상 더 큰 표본이 필요하다는 점을 기억하세요. 모든 계산은 브라우저에서 로컬로 실행되므로 입력한 데이터가 기기를 벗어나지 않습니다.

자주 묻는 질문

코드 구현

import math

# Z-values for common confidence levels
Z_VALUES = {80: 1.282, 85: 1.440, 90: 1.645, 95: 1.960, 99: 2.576}

def sample_size(confidence: int, margin_of_error: float, population: int = None) -> int:
    """
    Calculate required sample size.
    confidence: confidence level (80, 85, 90, 95, or 99)
    margin_of_error: as a decimal (e.g. 0.05 for 5%)
    population: total population size (None for infinite)
    """
    z = Z_VALUES[confidence]
    p = 0.5  # worst-case proportion
    n = (z ** 2 * p * (1 - p)) / (margin_of_error ** 2)

    if population is not None and population > 0:
        n = n / (1 + (n - 1) / population)

    return math.ceil(n)

# Examples
print(sample_size(95, 0.05))           # 385 (infinite population)
print(sample_size(95, 0.05, 1000))     # 278 (adjusted for N=1000)
print(sample_size(99, 0.03))           # 1842
print(sample_size(90, 0.05))           # 271

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.