How Pattern Recognition Works