Gravtiy/Tilt motion on Android device is twitching and very sensitive, is there a way to smooth this out?

I was implementing exactly the same solution as described by DG Gage
but an “average” by definition is always affected by the extremes of the data
that means that if at any moment you get an erratic value your whole array “history”
is affected for example 1,2,2,30,1 then you get a bad movement until the history
removes the “30”.
There is fashion/mode (maybe i am translating bad, my native language is spanish)
wich gives you the most repeated value from your data so i implemented it and got
nice results by combining it with average