def render_sample_results(self, output_port): print(latex.subsection("Notes"), file=output_port) num_sampled = sum((1 for v in self.stats_by_config.values() if v)) print("Sampled %s of %s configurations." % (num_sampled, self.get_num_configurations()), file=output_port) print(latex.table(["\# Typed", "\# Configs", "\# Samples", "Sample Mean", "Sample Variance", "95\% CI", "Standard Error", "Jarque-Bera"] ,[self.sample_stats((lambda cfg, nt=n: config.num_typed_modules(cfg) == n), n) for n in range(self.get_num_modules())]), file=output_port)
def random_sample(self, num_typed=None): matches = [cfg for cfg in self.all_configurations() if config.num_typed_modules(cfg) == num_typed] # Randomly select `sample_size` items from the population of `matches`. return [matches[random.randint(0, len(matches)-1)] for _ in range(self.sample_size)]