def simulate_number_of_words(nr_words): """ Simulations with a varying number of responses to a RAT problem. The simulation is run for the maximal number of words and based on that the success rates for a smaller number of words are calculated. """ performance = np.zeros((len(nr_words), 4)) max_words = nr_words[-1] # load an existing file try: filename = 'nr_words_simulation.npz' positions = np.load(filename)['positions'] print('Loading existing file...') except IOError: print('Running simulation!') positions, _ = simulate_test(**{'nr_words': max_words}) np.savez(filename, positions=positions) nr_items = float(len(positions)) for i, nr_w in enumerate(nr_words): print('Testing words = %d' % nr_w) solutions = np.where(positions < nr_w, positions, -1) performance[i, :3] = get_difficulties(solutions) percent_correct = 100 * len(np.where(solutions > -1)[0]) / nr_items performance[i, 3] = percent_correct return performance
def simulate_number_of_words(nr_words): """ Simulations with a varying number of responses to a RAT problem. The simulation is run for the maximal number of words and based on that the success rates for a smaller number of words are calculated. """ performance = np.zeros((len(nr_words), 4)) max_words = nr_words[-1] # load an existing file try: filename = 'nr_words_simulation.npz' positions = np.load(filename)['positions'] print('Loading existing file...') except IOError: print('Running simulation!') positions, _ = simulate_test(**{'nr_words': max_words}) np.savez(filename, positions=positions) nr_items = float(len(positions)) for i, nr_w in enumerate(nr_words): print('Testing words = %d' % nr_w) solutions = np.where(positions < nr_w, positions, -1) performance[i, :3] = get_difficulties(solutions) percent_correct = 100*len(np.where(solutions > -1)[0])/nr_items performance[i, 3] = percent_correct return performance
def simulate_threshold(thresholds, nr_words): """ Simulations with different thresholds. """ performance = np.zeros((len(thresholds), 4)) for i, th in enumerate(thresholds): print('Threshold = %.2f' % th) param = {'theta': th, 'nr_words': nr_words} positions, _ = simulate_test(**param) nr_items = len(positions) performance[i, :3] = get_difficulties(positions) percent_correct = 100 * len(np.where(positions > -1)[0]) / nr_items performance[i, 3] = percent_correct return performance
def simulate_threshold(thresholds, nr_words): """ Simulations with different thresholds. """ performance = np.zeros((len(thresholds), 4)) for i, th in enumerate(thresholds): print('Threshold = %.2f' % th) param = {'theta': th, 'nr_words': nr_words } positions, _ = simulate_test(**param) nr_items = len(positions) performance[i, :3] = get_difficulties(positions) percent_correct = 100*len(np.where(positions > -1)[0])/nr_items performance[i, 3] = percent_correct return performance
for i, sid in enumerate(cor_wr): c = 'g' if sid == 0: c = 'r' pl.plot(i, sid, 'o', color=c) pl.ylim([-.5, 1.5]) pl.xlabel('RAT Task ID') pl.ylabel('Correct (1) / Wrong (0)') print 'Performance:', success, '/', total print 'Success rate:', rate print 'Max position', solution_pos.max() pl.show() if __name__ == "__main__": param = {'nr_words': 5, 'theta': 0.0 } positions, responses = simulate_test(**param) easy, mid, hard = get_difficulties(positions) print 'Easy:', 100*easy print 'Mid:', 100*mid print 'Hard:', 100*hard # plot_statistics(positions)