diff --git a/statistics/src/draw_graph.py b/statistics/src/draw_graph.py index 81f855c..eb152b8 100755 --- a/statistics/src/draw_graph.py +++ b/statistics/src/draw_graph.py @@ -35,9 +35,23 @@ def draw_graph(self, data, title, xlabel, ylabel, tight_layout=False, mode="pair max_y_data: max y value for scale """ y_data = [] + tmp=0 for i in range(len(data.keys())): - y_data.append(np.mean(data[(data.keys())[i]])) - max_y_data = math.ceil(max(y_data)) + tmp=0 + for j in range(len(data[(data.keys())[i]])): + print "test: " + print data[(data.keys())[i]][j] + #print data[((data.keys())[i])[j]] + if data[(data.keys())[i]][j] == 1: + tmp += 1 + print tmp + y_data.append(tmp) + #y_data.append(np.mean(data[(data.keys())[i]])) + tmp_list = [] + for i in range(len(data.keys())): + tmp_list.append(len((data.keys())[i])) + #max_y_data = math.ceil(max(len(data.keys()))) + max_y_data = math.ceil(max(tmp_list)) """ y_error: calculate sample_error as list [err_0, err_1] left: list of x value for each bar, now it is just empty @@ -46,7 +60,10 @@ def draw_graph(self, data, title, xlabel, ylabel, tight_layout=False, mode="pair """ y_error = [] for i in range(len(data.keys())): - y_error.append(np.std(data[(data.keys())[i]], ddof=False)) + #y_error.append(np.std(data[(data.keys())[i]], ddof=False)) + y_error.append((len((data.keys())[i]) * np.std(data[(data.keys())[i]], ddof=False))) + print "y_error: " + print y_error left = np.array([]) """ left: list of x value (the number of order) for each bar @@ -106,7 +123,9 @@ def draw_graph(self, data, title, xlabel, ylabel, tight_layout=False, mode="pair add p value and mark """ if p < 0.05: - input_word = "**" + " (p = " + str(round (p * 1000.0) * 0.001) + " )" + #input_word = "**" + " (p = " + str(round (p * 1000.0) * 0.001) + " )" + print p + input_word = "**" + " (p = " + str(round (p * 100000.0) * 0.00001) + " )" plt.text(1.3, max_y_data * 0.75, input_word) elif p < 0.1: input_word = "*" + " (p = " + str(round (p * 1000.0) * 0.001) + " )" diff --git a/statistics/src/sample_t_test.py b/statistics/src/sample_t_test.py index 9d2c3db..2d0dd86 100755 --- a/statistics/src/sample_t_test.py +++ b/statistics/src/sample_t_test.py @@ -22,7 +22,16 @@ d.draw_graph(data, "test", "x", "y", tight_layout=True, mode="unpaired-ttest") elif args[1] == "paired-ttest": - # followed this website for sample: http://kogolab.chillout.jp/elearn/hamburger/chap5/sec1.html - data = {'HamburgerA': [90, 75, 75, 75, 80, 65, 75, 80], - 'HamburgerB' : [95, 80, 80, 80, 75, 75, 80, 85]} - d.draw_graph(data, "test", "x", "y", tight_layout=True) + # # followed this website for sample: http://kogolab.chillout.jp/elearn/hamburger/chap5/sec1.html + # data = {'HamburgerA': [90, 75, 75, 75, 80, 65, 75, 80], + # 'HamburgerB' : [95, 80, 80, 80, 75, 75, 80, 85]} + + # # children + data = {'Talking to the robot': [0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1], + 'Touching the robot': [0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1]} + d.draw_graph(data, "The number of children \nwho spontaneously interacted with the robot", "Action Type", "Number", tight_layout=True) + + # adult + # data = {'Talking to the robot': [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0], + # 'Touching the robot': [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0]} + # d.draw_graph(data, "The number of adults \nwho spontaneously interacted with the robot", "Action Type", "Number", tight_layout=True)