A self-optimizing non-linear filter