estimateProportionSampleSize

fun estimateProportionSampleSize(desiredHW: Double, pEst: Double = 0.5, level: Double = 0.95): Long(source)

Estimate the sample size for a proportion based on a normal approximation: the smallest whole n with z(1-alpha/2)*sqrt(p(1-p)/n) <= desiredHW, and never less than 1.

Return

the estimated sample size

Parameters

desiredHW

the desired half-width (must be bigger than 0)

pEst

an estimate of the proportion (must be between 0 and 1)

level

the confidence level (must be between 0 and 1)