def undecided_cases_priority(episode):
    """ Measures the indecision of the outuput of the policy by checking
			wether the second optimal choice is close in value to the first, the third 
			to the second and so on and so forth """
    var = 0
    for index in range(0, episode.length):
        ex_rew = list(episode.expected_rewards[index])
        length = 0
        ex_rew = ex_rew.sort()
        for i in range(1, length):
            if ex_rew[i] != 0:
                var += ex_rew[i - 1] / ex_rew[i] * i
            length += i
        if length != 0:
            var = var / length
    return var
