Exemple #1
0
    def test_median_mean(self):
        if TestCluster.module == 'Bio.Cluster':
            from Bio.Cluster import mean, median
        elif TestCluster.module == 'Pycluster':
            from Pycluster import mean, median

        data = numpy.array([34.3, 3, 2])
        self.assertAlmostEqual(mean(data), 13.1, places=3)
        self.assertAlmostEqual(median(data), 3.0, places=3)

        data = [5, 10, 15, 20]
        self.assertAlmostEqual(mean(data), 12.5, places=3)
        self.assertAlmostEqual(median(data), 12.5, places=3)

        data = [1, 2, 3, 5, 7, 11, 13, 17]
        self.assertAlmostEqual(mean(data), 7.375, places=3)
        self.assertAlmostEqual(median(data), 6.0, places=3)

        data = [100, 19, 3, 1.5, 1.4, 1, 1, 1]
        self.assertAlmostEqual(mean(data), 15.988, places=3)
        self.assertAlmostEqual(median(data), 1.45, places=3)
Exemple #2
0
def test_mean_median(module):
    if module == 'Bio.Cluster':
        from Bio.Cluster import mean, median
    elif module == 'Pycluster':
        from Pycluster import mean, median
    else:
        raise 'Unknown module name', module
    print "test_mean_median:"
    data1 = array([34.3, 3, 2])
    data2 = [5, 10, 15, 20]
    data3 = [1, 2, 3, 5, 7, 11, 13, 17]
    data4 = [100, 19, 3, 1.5, 1.4, 1, 1, 1]

    for data in [data1, data2, data3, data4]:
        print "data =",
        print_row(data)
        print "mean is %7.3f; median is %7.3f" % (mean(data), median(data))
    print
Exemple #3
0
def test_mean_median(module):
  if module=='Bio.Cluster':
    from Bio.Cluster import mean, median
  elif module=='Pycluster':
    from Pycluster import mean, median
  else:
    raise 'Unknown module name', module
  print "test_mean_median:"
  data1 = array([ 34.3, 3, 2 ])
  data2 = [ 5, 10 ,15, 20]
  data3 = [ 1, 2, 3, 5, 7, 11, 13, 17]
  data4 = [ 100, 19, 3, 1.5, 1.4, 1, 1, 1]

  for data in [data1, data2, data3, data4]:
    print "data =",
    print_row(data)
    print "mean is %7.3f; median is %7.3f" % (mean(data), median(data))
  print