Added code to use gap statistic to detect the value of K.