class Smoother:
	def __init__(self, alpha):
		self.a = alpha
		self.b = 1-alpha
		self.y = 0

	def initial(self, ic):
		self.y = ic

	def process(self, x):
		self.y = self.b*self.y + self.a*x
		return self.y

	def get_y(self):
		return self.y

class Stable:
	def __init__(self, stable_count, err_max):
		self.stable_time = stable_count
		self.count = stable_count
		self.err_max = err_max
		self.is_stable = 0
		self.x = 0

	def process(self, x):
		if self.count > 0:
			self.count -= 1

		if abs(x - self.x) >= self.err_max:
			self.count = self.stable_time

		self.is_stable = (self.count == 0)

		return self.is_stable

	def is_stable(self):
		return self.is_stable
