def cochran(data, p=0.5): mrgnerror = MarginOfError.marginoferror(data) q = 1 - mrgnerror z = ZScore.zscore(data) return (Exponentiation.power(z, 2) * p * q) / Exponentiation.power( mrgnerror, 2)
def SimpleSample(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 SimpleSample
def sample(list,p = 0.5,ci = 0.95): e = Margin_Error.error(list,ci) q = 1-p z = Zscore.ZscoreCalculatorUsingAlpha(ci) #print("Zvalue is ", z) #print("error value is: ",e) result = (Exponentiation.power(z,2)*p*q)/Exponentiation.power(e,2) return result
def samplenostdev(data, p = 0.5): zval = ZScore.zscore(data) merror = MarginOfError.marginoferror(data) q = 1 - p pq = p*q num = Exponentiation.power((zval/(merror/100)),2)*pq return round(num, 2)
def SamplSizeCalc(cvalue, error, p=0.5): zvalue = Zscore.ZscoreCalculatorUsingAlpha(cvalue) #print("zvalue is ", zvalue) q = 1 - p pq = p * q #print('pq value is ',pq) temp = Exponentiation.power((zvalue / (error / 100)), 2) * pq return round(temp, 2)
def sampleSize(sd, data): e = MarginError.marginError(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.marginError(sd, data) p = percentage q = 1 - p val = z/e sample = Exponentiation.exponent(val, 2) * p * q return sample
def deviation_Calculator(data): newdata = [] data.sort() n = len(data) mean = Mean.Mean_Calculator(data) for i in data: newdata.append(Exponentiation.power((i - mean),2)) sum = Addition.sumList(newdata) return nthRoot.rooting(2,Division.divide(sum,n))
def stardardDev(data): n = len(data) mn = Mean.mean(data) newlist = [] for i in data: newlist.append(Exponentiation.power(i - mn, 2)) total = Addition.sumList(newlist) return nthroot.root(2, Division.divide(total, n))
def test_MathOperations_Exponentiation(self): self.assertEqual(16, Exponentiation.power(4, 2))
def exponent(self, a, b): self.Result = Exponentiation.exponent(a, b) return self.Result
def variance(data): return Exponentiation.power(StandardDeviation.stardardDev(data), 2)
def Power(self, a, b): self.Result = Exponentiation.power(a, b) return self.Result
def exponent(self, a, b): self.result = Exponentiation.power(a, b) return self.result
def samplestdev(data): zval = ZScore.zscore(data) stdDev = StandardDeviation.stardardDev(data) merror = MarginOfError.marginoferror(data) num = Exponentiation.power(((zval * stdDev) / (merror / 100)), 2) return round(num, 2)
def test_MO_exp(self): self.assertEqual(8, Exponentiation.power(2, 3))
def Variance_Calculator(data): return Exponentiation.power( Standard_Deviation.deviation_Calculator(data), 2)