Start building sampling functions

Basic sampling code now working. Still needs docs
and possibly some clarifications.