This function computes the gap statistic which is used to test for an outlier using Daniels method
Useful links