Пример #1
0
class MedianOfLastWindow(object):
    def __init__(self, window_size):
        self._window = RandomDropSizedList(window_size)

    def __call__(self, sample=None):
        """If passed no sample then returns current median."""

        if sample is not None:
            # maintain order.
            self._window.insort(sample)
            # randomly expels one sample to keep size.  Dropping a random
            # sample exhibits no bias (as opposed to dropping smallest or
            # largest as done with MinWindow and MaxWindow)
        return median(self._window)
class MedianOfLastWindow(object):
    def __init__( self, window_size ):
        self._window = RandomDropSizedList(window_size)

    def __call__( self, sample = None ):
        """If passed no sample then returns current median."""

        if sample is not None:
            # maintain order.
            self._window.insort(sample)
               # randomly expels one sample to keep size.  Dropping a random
               # sample exhibits no bias (as opposed to dropping smallest or
               # largest as done with MinWindow and MaxWindow)
        return median(self._window)
Пример #3
0
 def __init__(self, window_size):
     self._window = RandomDropSizedList(window_size)
 def __init__( self, window_size ):
     self._window = RandomDropSizedList(window_size)