def cochranSample(data): p = 0.5 q = 1 - p p_q = product(p, q) List1 = [] List2 = [] for i in marginErr(data): List1.append(square(i)) for i in zScores(zValues(data)): List2.append(square(i)) i = 0 n = [] while i < len(List1): n.append(round(product(List1[i], p_q) / List2[i])) i += 1 return n
def CochranSampleSize(data): p = 0.5 q = 1 - p PQ = product(p, q) List = [] List1 = [] for i in MarginError(data): List.append(square(i)) for i in Z_scores(z_values(data)): List1.append(square(i)) i = 0 n = [] while i < len(List): n.append(round(product(List[i], PQ) / List1[i])) i += 1 return n
def sample_yes_std(data): List1 = [] List2 = [] e = marginErr(data) k = c_i(data) for i in k: Z = i[1] / 2 List1.append(scipy.stats.norm.cdf(Z)) i = 0 while i < len(List1): x = product(List1[i], StdDevSample(data)) y = round(division(x, e[i])) List2.append((square(y))) i += 1 return List2
def SampleSize_withStd(data): List = [] List1 = [] E = MarginError(data) K = mean_confidence_interval(data) for i in K: Z = i[1] / 2 List.append(scipy.stats.norm.cdf(Z)) i = 0 while i < len(List): x = product(List[i], StandardDeviationSample(data)) y = round(division(x, E[i])) List1.append((square(y))) i += 1 return List1
def Sample_Correlation(list1, list2): n = len(list1) avg_x = average(list1) avg_y = average(list2) rod = 0 x2 = 0 y2 = 0 for i in range(n): x = subtraction(list1[i], avg_x) y = subtraction(list2[i], avg_y) rod += product(x, y) x2 += square(x) y2 += square(y) return rod / squareRoot(x2 * y2)
def sample_no_std(data): e = marginErr(data) p = 0.5 q = 1 - p p_q = product(q, p) List1 = [] List2 = [] x = c_i(data) for i in x: Z = i[1] / 2 List1.append(scipy.stats.norm.cdf(Z)) m_e = [] for i in e: m_e.append(i / 2) i = 0 while i < len(m_e): ZE = List1[i] / m_e[i] x = round(square(ZE) * p_q) List2.append(x) i += 1 return List2
def SampleSize_withoutStd(data): E = MarginError(data) # return a list p = 0.5 q = 1 - p PQ = product(q, p) List = [] List1 = [] x = mean_confidence_interval(data) for i in x: Z = i[1] / 2 List.append(scipy.stats.norm.cdf(Z)) ME = [] for i in E: ME.append(i / 2) i = 0 while i < len(ME): ZE = List[i] / ME[i] x = round(square(ZE) * PQ) List1.append(x) i += 1 return List1
def product(self, a, b): self.result = product(a, b) return self.result