determining the most probable permutation of a set

New Member

Is there any way to determine the most probable permutation of any given set? For example, given the set of letters SKTANH, is there a way to compute that the most probable sequence of these letters is THANKS?

The background behind this question:

I've trained a recurrent neural network on War and Peace. Given any character it can predict the next. In fact if you feed its output into its input after the initial input, it can sort of write its own book of nonsense, even if all the words, spaces, and punctuation are used correctly. Pretty cool stuff.

The only problem with applying that network to the above question is that it won't constrain its output characters to those belonging to the input set. In other words, after T it may guess H is next. So far so good. But after H it might guess U. But there must be a way to utilize the learned "sequential probability distribution" (for lack of a better term) somehow.