estimateSampleSizeViaStudentT

fun estimateSampleSizeViaStudentT(desiredHW: Double, initStdDevEst: Double, level: Double = 0.95): Long(source)

Estimate the sample size based on iterating the half-width equation based on the Student-T distribution: the smallest n >= 2 with t(1-alpha/2, n-1)*s/sqrt(n) <= desiredHW.

The search starts at the normal-approximation answer from estimateSampleSize. Any n that meets the Student-T condition also meets the normal one, because t(1-alpha/2, n-1) exceeds the normal quantile for every finite degrees of freedom, so no smaller n can qualify. The Student-T half-width also falls strictly as n grows, so counting up from there stops at the smallest n that does.

Return

the estimated sample size

Parameters

desiredHW

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

initStdDevEst

an initial estimate of the standard deviation (must be bigger than or equal to 0)

level

the confidence level (must be between 0 and 1)