def product(self):
     return reduce(mul, self, ht(1))
 def median(self):
     xs = sorted(self)
     midpoint = round(len(xs) / 2)
     return xs[midpoint] if len(xs) % 2\
         else ht(xs[midpoint] + xs[midpoint-1]) / ht(2)
 def variance(self):
     return self.Sxx() / (len(self) - ht(1))
 def stdev(self):
     return self.variance()**ht('0.5')
 def __len__(self):
     return ht(super(type(self), self).__len__())
 def Sxx(self):
     return sum(self)**ht(2) - self.mean() * len(self)
예제 #7
0
 def test_rules(self):
     data = [[(self.x**2 + 3)**(ht(1)/ht(2)), 'x(x^2 + 3)^(-1/2)']]
     for y, s in data:
         print y, partial_differential(y, self.x), s
         assert str(partial_differential(y, self.x)) == s
 def norm(self):
     ''' Return the Euclidian Norm of a vector '''
     square = lambda a: a**2
     return sum(map(square, self))**ht('0.5')
 def product(self):
     return reduce(mul, self, ht(1))
 def median(self):
     xs = sorted(self)
     midpoint = round(len(xs)/2)
     return xs[midpoint] if len(xs) % 2\
         else ht(xs[midpoint] + xs[midpoint-1]) / ht(2)
 def stdev(self):
     return self.variance() ** ht('0.5')
 def variance(self):
     return self.Sxx() / (len(self) - ht(1))
 def Sxx(self):
     return sum(self)**ht(2) - self.mean() * len(self)
 def __len__(self):
     return ht(super(type(self), self).__len__())
 def norm(self):
     ''' Return the Euclidian Norm of a vector '''
     square = lambda a: a ** 2
     return sum(map(square, self))**ht('0.5')