Skip to content

Commit

Permalink
ergonomic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jpurnell committed Jun 11, 2024
1 parent 9586521 commit 58a2f0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public func requiredSampleSize<T: Real>(ci: T, stdDev: T, sampleMean: T, populat
/// print(result)
///
/// Use this function when planning a survey or experiment where it's important to understand population trends.
public func requiredSampleSizeProb<T: Real>(ci: T, prob: T, maxError: T, populationSize n: T?) -> T {
public func requiredSampleSizeProb<T: Real>(ci: T, prob: T, maxError: T, _ populationSize: T?) -> T {
let z = zScore(ci: ci)
let sampleSize = (T.pow(z, T(2)) * prob * (T(1) - prob))/(T.pow(maxError, T(2)))
guard let population = n else { return sampleSize }
guard let population = populationSize else { return sampleSize }
let populationCorrectionNumerator = T(1) + (T.pow(z, T(2)) * prob * (T(1) - prob))
let populationCorrectionDenominator = (T.pow(maxError, T(2)) * population)
let finitePopulationCorrection = populationCorrectionNumerator / populationCorrectionDenominator
Expand Down

0 comments on commit 58a2f0f

Please sign in to comment.