parameters: (requestContext, seriesList, points, windowTolerance=0.1)
return_statement: return seriesList
docstring: Takes one metric or a wildcard seriesList followed by an integer N.
    Draw the Standard Deviation of all metrics passed for the past N datapoints.
    If the ratio of null points in the window is greater than windowTolerance,
    skip the calculation. The default for windowTolerance is 0.1 (up to 10% of points
    in the window can be missing). Note that if this is set to 0.0, it will cause large
    gaps in the output anywhere a single point is missing.
  
    Example:
  
    .. code-block:: none
  
      &target=stdev(server*.instance*.threads.busy,30)
      &target=stdev(server*.instance*.cpu.system,30,0.0)
docstring_summary: Takes one metric or a wildcard seriesList followed by an integer N.
    Draw the Standard Deviation of all metrics passed for the past N datapoints.
    If the ratio of null points in the window is greater than windowTolerance,
    skip the calculation. The default for windowTolerance is 0.1 (up to 10% of points
    in the window can be missing). Note that if this is set to 0.0, it will cause large
    gaps in the output anywhere a single point is missing.
docstring_tokens: Takes one metric or a wildcard seriesList followed by an integer N . Draw the Standard Deviation of all metrics passed for the past N datapoints . If the ratio of null points in the window is greater than windowTolerance skip the calculation . The default for windowTolerance is 0 . 1 ( up to 10% of points in the window can be missing ) . Note that if this is set to 0 . 0 it will cause large gaps in the output anywhere a single point is missing .
function: def stdev(requestContext, seriesList, points, windowTolerance=0.1):
    """
    Takes one metric or a wildcard seriesList followed by an integer N.
    Draw the Standard Deviation of all metrics passed for the past N datapoints.
    If the ratio of null points in the window is greater than windowTolerance,
    skip the calculation. The default for windowTolerance is 0.1 (up to 10% of points
    in the window can be missing). Note that if this is set to 0.0, it will cause large
    gaps in the output anywhere a single point is missing.
  
    Example:
  
    .. code-block:: none
  
      &target=stdev(server*.instance*.threads.busy,30)
      &target=stdev(server*.instance*.cpu.system,30,0.0)
  
    """
  
    # For this we take the standard deviation in terms of the moving average
    # and the moving average of series squares.
    for (seriesIndex,series) in enumerate(seriesList):
      series.tags['stdev'] = points
      name = "stdev(%s,%d)" % (series.name, int(points))
      stdevSeries = series.copy(name=name, values=[])
  
      validPoints = 0
      currentSum = 0
      currentSumOfSquares = 0
      for (index, newValue) in enumerate(series):
        # Mark whether we've reached our window size - dont drop points out otherwise
        if index < points:
          bootstrapping = True
          droppedValue = None
        else:
          bootstrapping = False
          droppedValue = series[index - points]
  
        # Track non-None points in window
        if not bootstrapping and droppedValue is not None:
          validPoints -= 1
        if newValue is not None:
          validPoints += 1
  
        # Remove the value that just dropped out of the window
        if not bootstrapping and droppedValue is not None:
          currentSum -= droppedValue
          currentSumOfSquares -= droppedValue**2
  
        # Add in the value that just popped in the window
        if newValue is not None:
          currentSum += newValue
          currentSumOfSquares += newValue**2
  
        if validPoints > 0 and float(validPoints)/points >= windowTolerance:
          try:
            deviation = math.sqrt(validPoints * currentSumOfSquares - currentSum**2)/validPoints
          except ValueError:
            deviation = None
          stdevSeries.append(deviation)
        else:
          stdevSeries.append(None)
  
      seriesList[seriesIndex] = stdevSeries
  
    return seriesList
function_tokens: def stdev ( requestContext , seriesList , points , windowTolerance = 0.1 ) : # For this we take the standard deviation in terms of the moving average # and the moving average of series squares. for ( seriesIndex , series ) in enumerate ( seriesList ) : series . tags [ 'stdev' ] = points name = "stdev(%s,%d)" % ( series . name , int ( points ) ) stdevSeries = series . copy ( name = name , values = [ ] ) validPoints = 0 currentSum = 0 currentSumOfSquares = 0 for ( index , newValue ) in enumerate ( series ) : # Mark whether we've reached our window size - dont drop points out otherwise if index < points : bootstrapping = True droppedValue = None else : bootstrapping = False droppedValue = series [ index - points ] # Track non-None points in window if not bootstrapping and droppedValue is not None : validPoints -= 1 if newValue is not None : validPoints += 1 # Remove the value that just dropped out of the window if not bootstrapping and droppedValue is not None : currentSum -= droppedValue currentSumOfSquares -= droppedValue ** 2 # Add in the value that just popped in the window if newValue is not None : currentSum += newValue currentSumOfSquares += newValue ** 2 if validPoints > 0 and float ( validPoints ) / points >= windowTolerance : try : deviation = math . sqrt ( validPoints * currentSumOfSquares - currentSum ** 2 ) / validPoints except ValueError : deviation = None stdevSeries . append ( deviation ) else : stdevSeries . append ( None ) seriesList [ seriesIndex ] = stdevSeries return seriesList