Probabilistic approach to pattern selection