There is a much more straightforward and principled way: the Metropolis algorithm (http://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_alg...). You are basically sampling from the distribution of n-gram likelihoods by following a markov chain. Here is a javascript implementation: http://www.andrew.cmu.edu/user/tachim/page.html