Depends on what your unstable signal looks like.
Is your signal oscillating, and oscillating predictably? Then you could average the values out.
Is the signal mostly stable, with spike over- and undershoots? Then I would start with setting limits.
Is there a cause for noise in the signal? Maybe you can subtract the noise from your input signal?
This looks more a maths question than a Guide programming question.
BR
G