func (r *MedianFilter) Set(n float64) {
	r.instantaneous = n
	r.records[0] = n
	r.count = 1
}
Set = Reset + Add.
package movingaverage
import "github.com/montanaflynn/stats"
type MedianFilter struct {
	records       []float64
	size          uint64
	count         uint64
	instantaneous float64
}
func NewMedianFilter(size int) *MedianFilter {
	return &MedianFilter{
		records: make([]float64, size),
		size:    uint64(size),
	}
}
func (r *MedianFilter) Add(n float64) {
	r.instantaneous = n
	r.records[r.count%r.size] = n
	r.count++
}
func (r *MedianFilter) Get() float64 {
	if r.count == 0 {
		return 0
	}
	records := r.records
	if r.count < r.size {
		records = r.records[:r.count]
	}
	median, _ := stats.Median(records)
	return median
}
func (r *MedianFilter) Reset() {
	r.instantaneous = 0
	r.count = 0
}