Last active
November 25, 2017 02:57
-
-
Save codemartial/37a1dfa40f6accc2205268d2922cf8e9 to your computer and use it in GitHub Desktop.
Table of minimum percentages estimated using Adjusted Wald Method at 99% confidence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func max(l, r float64) float64 { | |
if l > r { | |
return l | |
} | |
return r | |
} | |
func adjWald(measuredRate, samplesCollected, samplesRequired float64) float64 { | |
zCritical := 2.58 // Magic number from statistics theory | |
populationFraction := (samplesRequired - samplesCollected) / (samplesRequired - 1.0) | |
rateUncertainty := math.Sqrt(populationFraction*measuredRate*(1-measuredRate)/samplesCollected) * zCritical | |
return measuredRate - rateUncertainty | |
} | |
func main() { | |
for ss := 99.0; ss < 1000.0; ss = ss + 100.0 { | |
for pct := 0.01; pct < 1.0; pct = pct * 2 { | |
fmt.Printf("%5.0f, %3.0f%%, %6.2f%%\n", ss, pct*100, max(0, adjWald(pct, ss, 1000.0))*100.0) | |
} | |
} | |
} | |
/* | |
Sample floors computed with Adjusted Wald Method at 99% confidence. | |
E.g. at Sample Size (SSize) of 199 and error rate (Rate) of 32%, | |
the Floor (minimum predicted error rate at 99% confidence) is 24.36%. | |
SSize, Rate, Floor | |
99, 1%, 0.00% | |
99, 2%, 0.00% | |
99, 4%, 0.00% | |
99, 8%, 1.32% | |
99, 16%, 6.97% | |
99, 32%, 20.51% | |
99, 64%, 52.18% | |
199, 1%, 0.00% | |
199, 2%, 0.00% | |
199, 4%, 0.79% | |
199, 8%, 3.56% | |
199, 16%, 10.00% | |
199, 32%, 24.36% | |
199, 64%, 56.14% | |
299, 1%, 0.00% | |
299, 2%, 0.25% | |
299, 4%, 1.55% | |
299, 8%, 4.61% | |
299, 16%, 11.42% | |
299, 32%, 26.17% | |
299, 64%, 58.00% | |
399, 1%, 0.00% | |
399, 2%, 0.60% | |
399, 4%, 2.04% | |
399, 8%, 5.28% | |
399, 16%, 12.33% | |
399, 32%, 27.33% | |
399, 64%, 59.19% | |
499, 1%, 0.19% | |
499, 2%, 0.85% | |
499, 4%, 2.40% | |
499, 8%, 5.78% | |
499, 16%, 13.00% | |
499, 32%, 28.18% | |
499, 64%, 60.07% | |
599, 1%, 0.34% | |
599, 2%, 1.06% | |
599, 4%, 2.69% | |
599, 8%, 6.19% | |
599, 16%, 13.55% | |
599, 32%, 28.88% | |
599, 64%, 60.79% | |
699, 1%, 0.47% | |
699, 2%, 1.25% | |
699, 4%, 2.95% | |
699, 8%, 6.55% | |
699, 16%, 14.04% | |
699, 32%, 29.50% | |
699, 64%, 61.43% | |
799, 1%, 0.59% | |
799, 2%, 1.43% | |
799, 4%, 3.20% | |
799, 8%, 6.89% | |
799, 16%, 14.50% | |
799, 32%, 30.09% | |
799, 64%, 62.03% | |
899, 1%, 0.73% | |
899, 2%, 1.62% | |
899, 4%, 3.46% | |
899, 8%, 7.26% | |
899, 16%, 15.00% | |
899, 32%, 30.72% | |
899, 64%, 62.69% | |
999, 1%, 0.97% | |
999, 2%, 1.96% | |
999, 4%, 3.95% | |
999, 8%, 7.93% | |
999, 16%, 15.91% | |
999, 32%, 31.88% | |
999, 64%, 63.88% | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment