We construct a random model to study the distribution of class numbers in special families of real quadratic fields ${\open Q}(\sqrt d )$ arising from continued fractions. These families are obtained by considering continued fraction expansions of the form $\sqrt {D(n)} = [f(n),\overline {u_1,u_2, \ldots ,u_{s-1} ,2f(n)]} $ with fixed coefficients u1, …, us−1 and generalize well-known families such as Chowla's 4n2 + 1, for which analogous results were recently proved by Dahl and Lamzouri [‘The distribution of class numbers in a special family of real quadratic fields’, Trans. Amer. Math. Soc. (2018), 6331–6356].