func NewMovingAverage(size int) Filter {
	return &MovingAverage{Window: size}
}
NewMovingAverage returns a moving average filter.
package filters
import (
	"fmt"
	"io"
	"math"
	"time"
)
type Filter interface {
	Check(interface{}) bool
	Update(interface{}) interface{}
}
type Model struct {
}
func (t *Model) Check(newValue interface{}) bool { return true }
func (t *Model) Update(newValue interface{}) interface{} {
	return newValue
}
type None struct {
	Model
}
type Sink struct {
	Model
}
func (s *Sink) Check(newValue interface{}) bool {
	return false
}
type Mute struct {
	Duration time.Duration
	previous time.Time
	Model
}
func (m *Mute) Check(newValue interface{}) bool {
	t := time.Now()
	if t.Sub(m.previous) < m.Duration {
		return false
	}
	m.previous = t
	return true
}
type Print struct {
	Writer io.Writer
	Prefix string
	Model
}
func (p *Print) Update(v interface{}) interface{} {
	_, err := fmt.Fprintf(p.Writer, "%s %v\n", p.Prefix, v)
	if err != nil {
		fmt.Printf("%s %v\n", p.Prefix, v)
	}
	return v
}
type OnChange struct {
	Value interface{}
}
func (t *OnChange) Check(newValue interface{}) bool { return t.Value != newValue }
func (t *OnChange) Update(newValue interface{}) interface{} {
	t.Value = newValue
	return newValue
}
type OnValue struct {
	Value interface{}
}
func (t *OnValue) Check(newValue interface{}) bool { return t.Value == newValue }
func (t *OnValue) Update(newValue interface{}) interface{} {
	return newValue
}
type AboveFloat64 struct {
	Value float64
}
func (t *AboveFloat64) Check(newValue interface{}) bool { return newValue.(float64) > t.Value }
func (t *AboveFloat64) Update(newValue interface{}) interface{} {
	return newValue
}
type BelowFloat64 struct {
	Value float64
}
func (t *BelowFloat64) Check(newValue interface{}) bool { return newValue.(float64) < t.Value }
func (t *BelowFloat64) Update(newValue interface{}) interface{} {
	return newValue
}
type MovingAverage struct {
	Window int
	values []float64
}