Translate KT estimation code to Julia.

Not really tested, other than to say that Julia will load it.