The numbers displayed in the suffix cells of the party-hours
heading are the mean and standard deviation of the counts
for which party-hours of effort are known. For a discussion of why we ignore columns with unknown
effort numbers, see Section 40, “
class NumberCell: Base class for numeric
The first step is to collect a sample set consisting of all
PartyHoursCell instances for which the
number is actually known.
# - - - S t a t R o w . s u f f i x e s def suffixes(self): '''Return the statistical cells at the end of a stat row. ''' #-- 1 # [ samples := values of the cells in self for which a # value is known ] samples = [ x for x in [ float(cell) for cell in self._cellList ] if x >= 0 ]
There are three ways to go from here. If there are no samples, we display hyphens in both columns. If there is exactly one sample, the mean is equal to that sample, and we display a hyphen in the standard deviation column. Only if there are two or more samples can we compute a standard deviation.
#-- 2 # [ if samples is empty -> # return a list of two LabelCells containing hyphens # else if samples has one element -> # return a list of a LabelCell displaying samples # and a LabelCell displaying a hyphen # else -> I ] if len(samples) == 0: return [StatCell(None), StatCell(None)] elif len(samples) == 1: return [StatCell(samples), StatCell(None)]
Actual statistical computation is done by Section 57, “
meanSigma(): Compute statistics”.
#-- 3 # [ return a list containing a StatCell displaying the mean # of samples and a StatCell displaying the standard # deviation of samples ] xbar, sigma = meanSigma(samples) return [ StatCell(xbar), StatCell(sigma) ]