def cochran(sd, data, rnge): z = Zscore.zscore(data) p = PopulationProportion.proportion(sd, data, rnge) e = MarginError.margin(sd, data) q = 1 - p cochran = (Exponentiation.exponent(z, 2) * p * q)/Exponentiation.exponent(e, 2) return cochran
def sampleSize(sd, data): e = MarginError.margin(sd, data) stdDev = StandardDeviation.standardDeviation(data) val = (1.96 * stdDev) / e sample = Exponentiation.exponent(val, 2) return sample
def sampleSize(sd, data, percentage): z = Zscore.zscore(sd, data) e = MarginError.margin(sd, data) p = percentage q = 1 - p val = z / e sample = Exponentiation.exponent(val, 2) * p * q return sample
def test_MathOperations_exponent(self): self.assertEqual(81, Exponentiation.exponent(9, 2))
def Exponent(self, a, b): self.Result = Exponentiation.exponent(a, b) return self.Result