adapting some functions so that they perform faster computations: PlotPattern() and all test statistics functions