コード例 #1
0
 def __init__(self, data, subject=''):
    self.subject = subject
    # It'd be a lot nicer to do these calculations using
    # http://www.python.org/dev/peps/pep-0450/ or even
    # https://pypi.python.org/pypi/stats/ instead of the
    # sometimes-difficult-to-install Numpy.  But alas, we're stuck with that for
    # Python 2.x.
    self.mean = data.mean()
    self.median = calcMedian(data) # I don't know why narray doesn't have self as a method.
    self.stdDev = data.std()
    self.min = data.min()
    self.max = data.max()
コード例 #2
0
def print_report(subject):
   '''Do various calculations on the subject, then print the results.
   
   This should be like, 8 different functions or something, but bad API design
   is easier.
   '''
   # It'd be a lot nicer to do these calculations using
   # http://www.python.org/dev/peps/pep-0450/ or even
   # https://pypi.python.org/pypi/stats/ instead of the
   # sometimes-difficult-to-install Numpy.  But alas, we're stuck with that for
   # Python 2.x.
   data = array(stats[subject])
   mean = data.mean()
   median = calcMedian(data) # I don't know why narray doesn't have this as a method.
   stdDev = data.std()
   min = data.min()
   max = data.max()
   print '%s: %s (mean) %s (median) %s (std. dev.) %s (min) %s (max)' \
       % (subject, mean, median, stdDev, min, max)

   initialize_ordered_dict(stats[subject+'Histogram'], range(min, max))
   
   print_histogram(stats[subject+'Histogram'].items())
コード例 #3
0
def print_report(subject):
    '''Do various calculations on the subject, then print the results.
   
   This should be like, 8 different functions or something, but bad API design
   is easier.
   '''
    # It'd be a lot nicer to do these calculations using
    # http://www.python.org/dev/peps/pep-0450/ or even
    # https://pypi.python.org/pypi/stats/ instead of the
    # sometimes-difficult-to-install Numpy.  But alas, we're stuck with that for
    # Python 2.x.
    data = array(stats[subject])
    mean = data.mean()
    median = calcMedian(
        data)  # I don't know why narray doesn't have this as a method.
    stdDev = data.std()
    min = data.min()
    max = data.max()
    print '%s: %s (mean) %s (median) %s (std. dev.) %s (min) %s (max)' \
        % (subject, mean, median, stdDev, min, max)

    initialize_ordered_dict(stats[subject + 'Histogram'], range(min, max))

    print_histogram(stats[subject + 'Histogram'].items())