first commit

Working functions, without much explanation due to not understanding the
workings of the sample function in R