javascript - Damping of value fluctuation, filtering out spikes -


i'm working physics in javascript , have value indicating number of contacts in "physical" world. value can between 0 - 6. problem fluctuates lot. want filter out spikes. number 3 , fraction of second changes 0 , 3 again. ideas how best this?

a fit can median filter in sliding window. consider last n values, n @ least twice duration of drop. filtered value median of n. repeat forever n samples shifted 1 position.

as values discrete in tiny range, median algorithm simple. keep histogram of 7 possible values, i.e. 7 counters. whenever shift 1 position, count down oldest value , count new. median value such cumulated counts reaches n/2.

there inertia, i.e. true changes take time acknowledged, unavoidable because algorithm needs confirm permanent change vs. temporary drop.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -