def get_reward_num_samples(block_index, goal, state_action_partition, max_threshold, goal_reward):
    """
    Give rewards for state-action blocks that have less samples than a threshold.
    :param block_index:                     Index of the state-action block.
    :param goal:                            True if this state-action block transitions into a goal state.
    :param state_action_partition:          State-action partition.
    :param max_threshold:                   Max samples.
    :param goal_reward:                     Goal state-action reward. The higher, the less exploration.
    :return:                                Reward.
    """

    if goal:
        # goal state-action
        return goal_reward
    else:
        # calculate reward based on how interesting a particular state-action block is
        return 1 - (min(len(state_action_partition.get(block_index)), max_threshold) / max_threshold)