def calMedian(a): length = len(a) half = int(division(2, length)) for val in a: exception(val) if length % 2 == 0: median = division(2, addition(a[half - 1], a[half])) else: median = a[half] return roundOff(median)
def proportion(size, corr): if corr is None: corr = 10 result = division(corr, size) return roundOff(result)
def calcPCC(xArray, yArray): xMean = calMean(xArray) yMean = calMean(yArray) length = len(xArray) xSd = stddev(xArray) ySd = stddev(xArray) total = 0 for i in range(0, length): total = addition( total, multiplication(division(xSd, subtraction(xMean, xArray[i])), division(ySd, subtraction(yMean, yArray[i])))) # total = subtraction(xMean, yArray[i]) res = division(length, total) return roundOff(res)
def confidenceInterval(array, conf): n = squareroot(len(array)) mean = calMean(array) sd = stddev(array) if conf == 80: t = 1.282 elif conf == 85: t = 1.440 elif conf == 90: t = 1.645 elif conf == 95: t = 1.960 else: # 99.5 default confidence percentage t = 2.807 ciLower = subtraction(multiplication(division(n, sd), t), mean) ciUpper = addition(mean, multiplication(division(n, sd), t)) return roundOff(ciLower), roundOff(ciUpper)
def zscore(a, mean, sd): # TODO: Make an array loop to verify all values return roundOff(division(sd, subtraction(mean, a)))
def varProportion(array, corr): n = len(array) prop = proportion(n, corr) res = division(n, multiplication(prop, subtraction(1, prop))) return roundOff(res)
def divide(self, a, b): self.result = round(division(a, b), 9) return self.result