def it_draws_from_the_expected_range(self): matrix = Factory.create_observation_matrix(sample_count=5) game = matrix.toGame() indexes = np.random.random_integers(0, game.max_samples - 1, size=1000) assert min(indexes) == 0 assert max(indexes) == 4 assert len(indexes) == 1000
def it_gives_the_requested_observations_with_duplicates(self): matrix = Factory.create_observation_matrix(sample_count=5) game = matrix.toGame() sbg = SimulationBasedGame(game) target_profile = game.knownProfiles()[0] observations = sbg.get_observations(target_profile, [0, 2, 2]) assert observations == { r: [ PayoffData( s, count, [ game.getPayoffData(target_profile, r, s)[0], game.getPayoffData(target_profile, r, s)[2], game.getPayoffData(target_profile, r, s)[2], ], ) for s, count in s_hash.items() ] for r, s_hash in target_profile.items() }
def it_provides_a_two_sided_confidence_interval(self): bootstrap_method = lambda *args: [i+1 for i in range(100)] ci = BootstrapConfidenceInterval(bootstrap_method) print ci.two_sided_interval(Factory.create_observation_matrix(), "fake profile", 0.90) assert ci.two_sided_interval(Factory.create_observation_matrix(), "fake profile", 0.95) == [3, 97]