Added online subsampling capabilities.

Plus unittests and extensive docstrings.