# Calculate the odds that a given name should have the first and last names swapped?

I have a personal project I'm working on and could use some help with the math. Let's say I had two lists.

FN: 1 million first names (dupes allowed).
LN: 2 million last names (dupes allowed).

And let's say we're looking at two names:

"Murray": Appears in FN 5,000 times and in LN 75,000 times.
"Harrison": Appears in FN 10,000 times and in LN 70,000 times.

I'm given "Murray Harrison" as a full name. How would you approach calculating the odds that the intended name was actually "Harrison Murray"? For the scope of this project, it is acceptable to assume that any last name is just as likely to appear next to any first name.

I think that:

P(Murray Harrison) = P(Murray as First) * P(Harrison as Last) = 5000/80000 * 70000/80000 = 0.055 P(Harrison Murray) = P(Harrison as First) * P(Murray as Last) = 75000/80000 * 10000/80000 = 0.117

Here's where my question might get tricky:

How would you take those two probabilities and determine the odds that the two names should be swapped? For example, say I decide that if there's a 95% chance they should be swapped, I'll swap them.

Would I need additional data to determine this probability? Would I just look at the probabilities of both name orders and if one's > 0.95 I would select that order?

Edit: To be clear, I have a list of full names and I want to programmatically determine which name is the first name, and which is the last. Sometimes the data will be in Last-First order (without a comma) and sometimes it will be in First-Last order. I'm trying to use a bit of stats to determine the most likely order.

• Not sure if I understand. What do you mean by swapping? You say it like when you get a harrison or a murray, you do not know if it is a LN or FN. Is that so? Sep 29 '13 at 22:09
• That is correct (see my recent edit). I have a list of full names where the order is inconsistent. Sep 29 '13 at 22:33
• If P(Murray Harrison)=.055 and P(Harrison Murray) = .117, you are .117/.055=2.1 times likely to get a Harrison Murray than a Murray Harrison. If you want percentages, the chance that you have a Harrison Murray is .117/(.117+.055)=68%. This should be a start, but I am still puzzled. How did you figure out that Murray appears in FN 5,000 times and in LN 75,000 times without knowing whether it is a FN or LN?? Sep 30 '13 at 1:59
• Imagine you have a list of full names (two "words" long) but you have no confidence that they're in the correct order. How do you determine which "word" is the first name, and which is the last name? What you can do is see how many times the first word appears in the entire world as a first name, and how often it appears as a last name. Then you can calculate odds. FN, for our purposes, is treated like it has every first name in the world. So, I take "Murray", and calculate the odds that it's being used as a first name rather than a last. Does that make more sense? Sep 30 '13 at 6:12
• Sorry, I'm further lost. And it's probably why no one else is answering. As soon as you said "... the first word appears..." it doesn't make sense. You're saying there is no order to the combination of words, so it makes no sense that you do know which one is the first or last word. Sep 30 '13 at 11:38

$$Odds(reversed|name) = Odds(reversed) \frac{P(name|reversed)}{P(name|correct)}$$