Original Software and Algorithm written in R and C++