import scipy.stats as stats import numpy as np control = [3, 4, 5, 4, 3, 3, 4, 5, 4, 3, 2, 1, 4] experimental = [1, 3, 2, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4] #calculating wilcoxon result = stats.wilcoxon(control, experimental) w = result.statistic p = result.pvalue pairs = len(np.array(control)) differences = np.array(control) - np.array(experimental) n = np.sum(differences != 0) #calculating standard deviation difference_1 = np.sum(np.absolute(differences) == 1) difference_2 = np.sum(np.absolute(differences) == 2) difference_3 = np.sum(np.absolute(differences) == 3) difference_4 = np.sum(np.absolute(differences) == 4) differences = [difference_1, difference_2, difference_3, difference_4] sigmastddev2 = 0 for difference in differences: calculation = (int(difference)*int(difference)*int(difference) - int(difference)) / 2 sigmastddev2 += calculation newcalc = sigmastddev2 standarddeviation = np.sqrt(((n * (n + 1) * (2 * n + 1)) - sigmastddev2) / 24) #calculating expected value of w mu_w = (n * (n+1) / 4) print(f"expected value of w: {mu_w}") #calculating z-value z_value = (w - mu_w) / standarddeviation print(f"z value: {z_value}")
submitted by /u/smores_or_pizzasnack
[link] [comments]
r/learnpython import scipy.stats as stats import numpy as np control = [3, 4, 5, 4, 3, 3, 4, 5, 4, 3, 2, 1, 4] experimental = [1, 3, 2, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4] #calculating wilcoxon result = stats.wilcoxon(control, experimental) w = result.statistic p = result.pvalue pairs = len(np.array(control)) differences = np.array(control) – np.array(experimental) n = np.sum(differences != 0) #calculating standard deviation difference_1 = np.sum(np.absolute(differences) == 1) difference_2 = np.sum(np.absolute(differences) == 2) difference_3 = np.sum(np.absolute(differences) == 3) difference_4 = np.sum(np.absolute(differences) == 4) differences = [difference_1, difference_2, difference_3, difference_4] sigmastddev2 = 0 for difference in differences: calculation = (int(difference)*int(difference)*int(difference) – int(difference)) / 2 sigmastddev2 += calculation newcalc = sigmastddev2 standarddeviation = np.sqrt(((n * (n + 1) * (2 * n + 1)) – sigmastddev2) / 24) #calculating expected value of w mu_w = (n * (n+1) / 4) print(f”expected value of w: {mu_w}”) #calculating z-value z_value = (w – mu_w) / standarddeviation print(f”z value: {z_value}”) submitted by /u/smores_or_pizzasnack [link] [comments]
import scipy.stats as stats import numpy as np control = [3, 4, 5, 4, 3, 3, 4, 5, 4, 3, 2, 1, 4] experimental = [1, 3, 2, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4] #calculating wilcoxon result = stats.wilcoxon(control, experimental) w = result.statistic p = result.pvalue pairs = len(np.array(control)) differences = np.array(control) - np.array(experimental) n = np.sum(differences != 0) #calculating standard deviation difference_1 = np.sum(np.absolute(differences) == 1) difference_2 = np.sum(np.absolute(differences) == 2) difference_3 = np.sum(np.absolute(differences) == 3) difference_4 = np.sum(np.absolute(differences) == 4) differences = [difference_1, difference_2, difference_3, difference_4] sigmastddev2 = 0 for difference in differences: calculation = (int(difference)*int(difference)*int(difference) - int(difference)) / 2 sigmastddev2 += calculation newcalc = sigmastddev2 standarddeviation = np.sqrt(((n * (n + 1) * (2 * n + 1)) - sigmastddev2) / 24) #calculating expected value of w mu_w = (n * (n+1) / 4) print(f"expected value of w: {mu_w}") #calculating z-value z_value = (w - mu_w) / standarddeviation print(f"z value: {z_value}")
submitted by /u/smores_or_pizzasnack
[link] [comments]