self.cut_off_pos = [0] * (len(self.V)+1) for a in self.ad.number_of_v_removed: self.cut_off_pos[a] = self.ad.number_of_v_removed[a] if __name__ == "__main__": increment = 1 iterations = 18 average_over = 10 iter_nums = [x*increment + increment for x in xrange(iterations)] p_results = [0] * iterations for j in xrange(average_over): for i in xrange(iterations): print j, i a = Attack(200, 40, iter_nums[i]) a.attack(100) p_vals = binom_stats(a.sorted_tally, 100) p_results[i] += sum(p_vals)/len(p_vals) p_results = [x / average_over for x in p_results] plt.plot(iter_nums, p_results); plt.xlabel("Threshold") plt.ylabel("p value") plt.show() raw_input()
self.cut_off_pos = [0] * (len(self.V)+1) for a in self.ad.number_of_v_removed: self.cut_off_pos[a] = self.ad.number_of_v_removed[a] if __name__ == "__main__": iterations = 200 increment = 25 average_over = 10 min_p_vals = [0] * iterations iterations_array = [i*increment + increment for i in xrange(iterations)] for j in xrange(average_over): a = Attack(200, 20, 3) for i in xrange(iterations): print j, i a.attack(increment) p_vals = binom_stats(a.sorted_tally, iterations_array[i]) min_p_vals[i] += min(p_vals) min_p_vals = [x/average_over for x in min_p_vals] fig = plt.figure() ax = fig.add_subplot(121) ax.plot(iterations_array, min_p_vals, 'b-', label="Minimum p-value") ax.plot(iterations_array, [0.05] * iterations, 'r--', label="0.05 level of confidence") ax.plot(iterations_array, [0.01] * iterations, 'm--', label="0.01 level of confidence") ax.set_xlabel("Number of attacks") ax.set_ylabel("Level of confidence") ax.legend(bbox_to_anchor=(1.05, 0.5), loc=6, borderaxespad=0.) fig.show()