From ac38e1f1f5e0ec42fe98e320a62067154f425e71 Mon Sep 17 00:00:00 2001 From: Kanae Kochigami Date: Wed, 4 Oct 2017 19:51:38 +0900 Subject: [PATCH 1/3] added temporaly change --- statistics/src/draw_graph.py | 4 +++- statistics/src/sample_t_test.py | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/statistics/src/draw_graph.py b/statistics/src/draw_graph.py index 81f855c..b394a39 100755 --- a/statistics/src/draw_graph.py +++ b/statistics/src/draw_graph.py @@ -106,7 +106,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..315bbb3 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, 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, 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, "Average ratio of children who touched or talked to the robot", "Action", "Ratio", 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, "Average ratio of adults who touched or talked to the robot", "Action", "Ratio", tight_layout=True) From 215dd277ea366eeff8a8f8137e623bfcb158077f Mon Sep 17 00:00:00 2001 From: Kanae Kochigami Date: Thu, 5 Oct 2017 21:42:23 +0900 Subject: [PATCH 2/3] update y data display --- statistics/src/draw_graph.py | 23 ++++++++++++++++++++--- statistics/src/sample_t_test.py | 12 ++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/statistics/src/draw_graph.py b/statistics/src/draw_graph.py index b394a39..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 diff --git a/statistics/src/sample_t_test.py b/statistics/src/sample_t_test.py index 315bbb3..2a0ea6c 100755 --- a/statistics/src/sample_t_test.py +++ b/statistics/src/sample_t_test.py @@ -27,11 +27,11 @@ # '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, 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, 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, "Average ratio of children who touched or talked to the robot", "Action", "Ratio", tight_layout=True) + 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, 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, 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, "Average ratio of adults who touched or talked to the robot", "Action", "Ratio", tight_layout=True) + # 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) From 92668093adc97ca020c1bc57b4f831f3ece1b64e Mon Sep 17 00:00:00 2001 From: Kanae Kochigami Date: Thu, 12 Oct 2017 10:41:21 +0900 Subject: [PATCH 3/3] add one sample --- statistics/src/sample_t_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/statistics/src/sample_t_test.py b/statistics/src/sample_t_test.py index 2a0ea6c..2d0dd86 100755 --- a/statistics/src/sample_t_test.py +++ b/statistics/src/sample_t_test.py @@ -27,8 +27,8 @@ # '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, 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, 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]} + 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