Example #1
0
 def testMidWeight(self):
     x = [0, 1.2, 4]
     weights = [1, 98, 1]
     for i in xrange(2, 99):
         self.assertAlmostEqual(
             1.2, ycsb._WeightedQuantile(x, weights, i / 100.0))
     self.assertEqual(4, ycsb._WeightedQuantile(x, weights, 0.995))
Example #2
0
 def testEvenlyWeightedSamples(self):
     x = range(1, 101)  # 1-100
     weights = [1 for _ in x]
     self.assertEqual(50, ycsb._WeightedQuantile(x, weights, 0.50))
     self.assertEqual(75, ycsb._WeightedQuantile(x, weights, 0.75))
     self.assertEqual(90, ycsb._WeightedQuantile(x, weights, 0.90))
     self.assertEqual(95, ycsb._WeightedQuantile(x, weights, 0.95))
     self.assertEqual(99, ycsb._WeightedQuantile(x, weights, 0.99))
     self.assertEqual(100, ycsb._WeightedQuantile(x, weights, 1))
Example #3
0
 def testEvenlyWeightedSamples(self):
   x = range(1, 101)  # 1-100
   weights = [1 for _ in x]
   self.assertEqual(50, ycsb._WeightedQuantile(x, weights, 0.50))
   self.assertEqual(75, ycsb._WeightedQuantile(x, weights, 0.75))
   self.assertEqual(90, ycsb._WeightedQuantile(x, weights, 0.90))
   self.assertEqual(95, ycsb._WeightedQuantile(x, weights, 0.95))
   self.assertEqual(99, ycsb._WeightedQuantile(x, weights, 0.99))
   self.assertEqual(100, ycsb._WeightedQuantile(x, weights, 1))
Example #4
0
 def testLowWeight(self):
     x = [1, 4]
     weights = [99, 1]
     for i in xrange(100):
         self.assertEqual(1, ycsb._WeightedQuantile(x, weights, i / 100.0))
     self.assertEqual(4, ycsb._WeightedQuantile(x, weights, 0.995))
Example #5
0
 def testMidWeight(self):
   x = [0, 1.2, 4]
   weights = [1, 98, 1]
   for i in xrange(2, 99):
     self.assertAlmostEqual(1.2, ycsb._WeightedQuantile(x, weights, i / 100.0))
   self.assertEqual(4, ycsb._WeightedQuantile(x, weights, 0.995))
Example #6
0
 def testLowWeight(self):
   x = [1, 4]
   weights = [99, 1]
   for i in xrange(100):
     self.assertEqual(1, ycsb._WeightedQuantile(x, weights, i / 100.0))
   self.assertEqual(4, ycsb._WeightedQuantile(x, weights, 0.995))