Ejemplo n.º 1
0
 def test_variance_method_calculator(self):
     calculator = Calculator()
     random_generator = RandomGenerator()
     test_list = random_generator.rand_list(self, 0, 100, 5, 3)
     variance = calculator.variance(test_list)
     self.assertEqual(calculator.variance(test_list), variance)
     self.assertEqual(calculator.result, variance)
Ejemplo n.º 2
0
 def test_std_dev_method_calculator(self):
     calculator = Calculator()
     random_generator = RandomGenerator()
     test_list = random_generator.rand_list(self, 0, 100, 5, 3)
     std_dev = calculator.standard_dev(test_list)
     self.assertEqual(calculator.standard_dev(test_list), std_dev)
     self.assertEqual(calculator.result, std_dev)
Ejemplo n.º 3
0
 def test_z_score_method_calculator(self):
     calculator = Calculator()
     random_generator = RandomGenerator()
     test_list = random_generator.rand_list(self, 0, 100, 5, 3)
     test_score = 10
     z_score = calculator.z_score(test_list, test_score)
     self.assertEqual(calculator.z_score(test_list, test_score), z_score)
     self.assertEqual(calculator.result, z_score)
Ejemplo n.º 4
0
 def test_mode_method_calculator(self):
     calculator = Calculator()
     random_generator = RandomGenerator()
     test_list = random_generator.rand_list(self, 0, 100, 5, 3)
     values_mode = calculator.mode(test_list)
     self.assertEqual(calculator.mode(test_list), values_mode)
     self.assertEqual(calculator.result, values_mode)
     test_list.clear()
Ejemplo n.º 5
0
 def test_median_method_calculator(self):
     calculator = Calculator()
     random_generator = RandomGenerator()
     test_list = random_generator.rand_list(self, 0, 100, 5, 3)
     median = calculator.median(test_list)
     self.assertEqual(calculator.median(test_list), median)
     self.assertEqual(calculator.result, median)
     test_list.clear()
Ejemplo n.º 6
0
class PopulationSamplingTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.random_generator = RandomGenerator()
        self.pop_sampling = PopulationSampling()

    def test_instantiate_pop_sampling(self):
        self.assertIsInstance(self.pop_sampling, PopulationSampling)

    def test_instantiate_rand_gen(self):
        self.assertIsInstance(self.random_generator, RandomGenerator)

    def test_simple_rand(self):
        test_list = self.random_generator.rand_list(self, 0, 10, 50, 3)
        result = self.pop_sampling.simple_rand(self, test_list, 10, 5)
        self.assertEqual(self.pop_sampling.simple_rand(self, test_list, 10, 5),
                         result)
        test_list.clear()

    def test_margin_error(self):
        test_list = [4, 9, 3, 6, 8, 2, 1, 8, 5, 9]
        self.assertEqual(
            round(self.pop_sampling.margin_error(self, test_list), 6),
            1.736564)
        test_list.clear()

    def test_confidence_interval(self):
        test_list = [4, 9, 3, 6, 8, 2, 1, 8, 5, 9]
        self.assertEqual(
            self.pop_sampling.confidence_interval(self, test_list),
            [7.236564, 3.763436])
        test_list.clear()

    def test_cochran_formula(self):
        test_list = self.random_generator.rand_list(self, 1, 100, 1000, 5)
        self.assertEqual(
            self.pop_sampling.cochran_formula(self, test_list, .5), 437)
        test_list.clear()

    def test_confidence_width(self):
        width = .06
        self.assertEqual(self.pop_sampling.confidence_width(self, width, .41),
                         1033)
Ejemplo n.º 7
0
 def setUp(self) -> None:
     self.random_generator = RandomGenerator()
Ejemplo n.º 8
0
 def test_random_choices_with_seed(self):
     random_generator = RandomGenerator()
     values = [8, 22, 30, 13, 15, 70]
     random_choices = random_generator.rand_choices_seed(self, values, 4, 7)
     self.assertEqual(random_generator.rand_choices_seed(self, values, 4, 7), random_choices)
Ejemplo n.º 9
0
 def test_random_choices_without_seed(self):
     random_generator = RandomGenerator()
     values = [7, 21, 29, 12, 14, 69]
     random_choices = random_generator.rand_choices(self, values, 3)
     print(random_choices)
Ejemplo n.º 10
0
 def test_random_choice_with_seed(self):
     random_generator = RandomGenerator()
     values = [6, 20, 28, 11, 13, 68]
     random_choice = random_generator.rand_choice_seed(self, values, 5)
     self.assertEqual(random_generator.rand_choice_seed(self, values, 5), random_choice)
Ejemplo n.º 11
0
 def test_random_choice_without_seed(self):
     random_generator = RandomGenerator()
     values = [5, 19, 27, 10, 12, 67]
     random_choice = random_generator.rand_choice(self, values)
     print(random_choice)
Ejemplo n.º 12
0
 def test_random_list_with_seed(self):
     random_generator = RandomGenerator()
     random_list = random_generator.rand_list(self, 0, 100, 10, 5)
     self.assertEqual(random_generator.rand_list(self, 0, 100, 10, 5), random_list)
Ejemplo n.º 13
0
 def test_random_number_with_seed(self):
     random_generator = RandomGenerator()
     random_number = random_generator.rand_seed(self, 0, 100, 10)
     self.assertEqual(random_generator.rand_seed(self, 0, 100, 10), random_number)
Ejemplo n.º 14
0
 def test_random_number_without_seed(self):
     random_generator = RandomGenerator()
     print(random_generator.rand(self, 0, 100))
Ejemplo n.º 15
0
 def setUp(self) -> None:
     self.random_generator = RandomGenerator()
     self.pop_sampling = PopulationSampling()