[MRG] Enhance and fix perceptron implementation

Fix an embarrassing bug, add a test, simplify averaging a bit.

TODO:

- [x] perform moving average to prevent overflow (failing test)
- [x] implement ~~`average=-k` or maybe just~~ `average=-1` as a special case.
- [x] add the reference to structured and averaged perceptron.