def it_can_add_observations_to_existing_profiles(self):
     matrix = ObservationMatrix([{'All': [PayoffData('A', 2, [12, 11])]},
                                 {'All': [PayoffData('A', 1, [23]), PayoffData('B', 1, [11])]},
                                 {'All': [PayoffData('B', 2, [13.3])]}])
     matrix.addObservations(Profile({'All': {'A': 1, 'B': 1}}),
                            {'All': [PayoffData('A', 1, [12, 11]), PayoffData('B', 1, [21, 17])]})
     assert matrix.getPayoffData(Profile({'All': {'A': 1, 'B': 1}}), 'All', 'B') == [11, 21, 17]
 def it_does_not_request_sampling_when_only_profiles_outside_target_set_have_too_much_variation_in_payoffs(self):
     matrix = ObservationMatrix()
     target_profile = Profile({'All': {'A': 2}})
     non_target_profile = Profile({'All': {'B': 2}})
     matrix.addObservations(target_profile, {'All': [PayoffData('A', 2, [10, 10.1, 10.2])]})
     matrix.addObservations(non_target_profile, {'All': [PayoffData('B', 2, [10, 20, 45])]})
     evaluator = StandardErrorEvaluator(1, [target_profile])
     assert evaluator.continue_sampling(matrix) == False
def add_noise_sequentially(game, model, evaluator, samples_per_step):
    """
    Generate ObservationMatrix sequentially with bimodal gaussian noise added to each payoff.
    
    game: a RSG.Game or RSG.SampleGame
    model: noise model
    samples_per_step: the parameters passed to the noise function
    evaluator: the method used to determine when to stop sampling
    """
    matrix = ObservationMatrix()
    count = 0
    while evaluator.continue_sampling(matrix) and count < 1000:
        for prof in game.knownProfiles():
            matrix.addObservations(prof, model.generate_samples(game, prof, samples_per_step))
        count += samples_per_step
        print count
    return [matrix, evaluator.equilibria()]
 def it_can_add_observations_for_previously_unobserved_profiles(self):
     matrix = ObservationMatrix()
     matrix.addObservations(Profile({'All': {'A': 1, 'B': 1}}),
                            {'All': [PayoffData('A', 1, [12, 11]), PayoffData('B', 1, [21, 17])]})
     assert matrix.getPayoffData(Profile({'All': {'A': 1, 'B': 1}}), 'All', 'B') == [21, 17]