Source: https://centerforstatistics-ugent.github.io/smooth2/R-Package_files/Smoothtest_for_Mac.pdf