Count the dinucleotides inside the CpG islands of chromosome 8 and outside them, and normalise each row: two transition matrices, Pi and Pn. A sequence x1…xL then gets the log-likelihood-ratio score αx1 + Σt βxt−1xt, with βxy = log(Pixy/Pnxy) and α the log-ratio of the letter frequencies. Positive scores favour "island". Score your own sequence, or compare the per-base scores of real island and background windows: the classes separate better as the window grows.
code/ch02_statistical_modeling.R (cpg_data, cpg_model, cpg_score, Figure 2.27). This page reproduces the score of the book's example (−0.2825).