# Description

I've got a series of events (points, objects, letters, what have you) that occur during a labeled time period (category.) Events can happen during multiple categories. I want to find the event which is most representative of each category. Put another way, for each category, I want to find the event that happens most often that doesn't happen often in other categories.

# Example

How about a rough example of what I want to do? Here are some categories, and beneath them the events that belong to them:

I would like to have an algorithm that outputs:

• Apples: A
• Oranges: C
• Kiwis: B

I don't want D selected for any since it happens roughly equally in all categories

• For each category, get a total for each event type. Find the largest and second largest number of events for each event type, and subtract. The event type with the highest resulting number wins. – Robert Harvey Aug 9 '16 at 21:26

One way is to simply find the probability that any given event (capital letter) is in any category. For example count all the A's and divide each category of A by that total.

``````         A   B   C   D
apple:  12,  3,  1, 32
oranges: 5,  3,  8, 32
kiwis:   3, 12,  2, 32
total:  20, 18, 11, 96

A    B      C       D
apple:  0.6! 0.167  0.091   0.333
oranges:0.25 0.167  0.727!  0.333
kiwis:  0.15 0.667! 0.182   0.333
``````

Then just pick the event with the highest probability in each category. The !'s win.

Another way that's a little harder on the brain, but easier on the computer, is to multiply everything by every total except it's own total. For example multiply the 12 apple A's by 18, 11, and 96 but not 20. This gives the same effect as expensive division but without asking the computer to divide anything. Now you can stick with nice whole numbers.

``````            A      B       C      D
apple:   228096! 63360   34560  126720
oranges:  95040  63360  276480! 126720
kiwis:    57024 253440!  69120  126720
``````

Choose the biggest in it's category. The !'s win again.

• What you describe is relative frequencies(%) and not probabilities – John Kouraklis Aug 17 '16 at 17:07