What are the statistical tools for distinguishing molecular analogy from homology?
There are lots of statistical algorithms that allow you to evaluate the similarity between two given sequences. For instance, blast allows you a rapid comparison between your sequence and other sequences in a database; while Clustal, with a similar functioning, allows you to compare a set of given sequences between them. They are very simple algorithms, but very fast and useful, and basically they score an alignment by counting how many positions between the two entries are the same. Other algorithms function in a similar fashion, but they use hidden Markov models to compare your sequence with a consensual sequence in order to identify motifs and domains. I'm sure there are even more advanced programs, but I don't know them and don't think it's the point.

Homology usually refers to things that share the same origin, while analogy refers to things that do the same function but their origin isn't shared. While the algorithms I've described you only search for similarity or identity, you must notice a few things:

a) Homology of function doesn't necessarily correlate with high similarity. Two proteins can have the same global structure and their sequences be completely different. The three-dimensional structure is the same, and probably there'll be key amino acids that will remain very similar. This is very obvious in many proteases, which share only the three catalytic amino acids (catalytic triad) between them, and vary enormously even between strains of the same species.

b) Protein domains vary in size from a few dozen to a few hundred amino acids. The odds that exactly the same sequence evolves in two separate moments are very low. Especially in highly conserved domains, which usually carry out key functions.

c) Proteins usually have a modular structure with more than one domain. New proteins often evolve by switching and combining domains by translocation. So, even if the same domain has evolved in two separate times, the association between these two "twin" domains with other domains will probably reveal its unusual origin.

That's why usually the term molecular analogy is not used, and if so, it would refer for example to structurally different domains that catalyze the same reaction or that share the same structure. Note that even if the analogy as you describe isn't impossible by itself, the software won't be able to differentiate them unless the sequence appears associated with others. Furthermore, the origin of many of the current protein families is so far in the past that it's quite impossible to reconstruct it, even more so with the high diversity in prokaryotes.