0

I created a software program that uses the information from Stats Canada Crime data and searches through the crime data file to organize and parse the information. My program asks the user which two provinces they want to compare, which crime they want to look at and for which year. The question format is similar to this:

Does location a have a higher rate of crime b than location c for the year d.

In this scenario, there are 14 different option for a, 10 different options for b, 14 different options for c and 17 options for the year d.

I wanted to know how many different ways the above question can be phrased, keeping in mind that the options for a and c are the same. I'm not entirely sure how to approach this and have read up on permutations and combinations but none of the information I found was suitable for the problem I'm trying to solve.

Would appreciate some guidance and insight

kash
  • 3
  • But how options of a and c can be same? As a and c are two different locations. – Kanwaljit Singh Apr 09 '17 at 02:33
  • By that I mean that the order of a and c matter. Because I wanted to do direct comparison between provinces i have 14 locations to choose from for both options. – kash Apr 09 '17 at 02:35

2 Answers2

1

You need the rule of product or multiplication principle. If you have $14$ choices for $a$ and $10$ choices for $b$ you have $14 \times 10=140$ choices for the pair as long as no choice for $a$ invalidates some choices for $b$. If you prohibit $a$ and $c$ being the same there are $14$ choices for $a$ but only $13$ for $c$. In that case the number of options is $14\times 10 \times 13 \times 17=30940$

This sort of computation is useful in software design. You clearly need to store data for $14 \times 10 \times 17=2380$ cases of location, crime, and year as that is the data you have. If somebody makes an inquiry you need to look up two of the entries in the database and report the results. You have an option to store the data for all pairs of location. That requires $13$ times as much storage but only requires looking into the database once. If the database is very slow, that might be a good trade.

Ross Millikan
  • 374,822
  • The part I'm confused about is that the order of a and c matter. The 14 options are (Canada, ON, QB, PEI, NS, NB, NFLD, MB, SK, AB, BC, NWT, YK, NVT)

    This means that if the person choose QB for a and then ON for c, then that's the same thing as them doing ON for a and QB for c. I want to avoid that redundancy in the calculation. Does this take care of it?

    – kash Apr 09 '17 at 02:40
  • If you just want to provide two pieces of data, the order of a and c don't matter and you can divide the number of possibilities by $2$. That would apply if you just want to report the results for ON and YK but don't care which order you report them in. If you want to say how much worse is ON than YK you care about the order because the sign will change if they ask how much worse is YK than ON. – Ross Millikan Apr 09 '17 at 02:43
  • Because my program iterates through a large csv file, regardless of which option the user chooses first, whichever result the program finds first it will print out. My program simply answers the question "Which province has the greater rate of the specified crime in specified year" and gives an output similar to "Ontario has a higher rate of murder than Quebec in 2014". In that case there are 15740 possible outputs for my program, correct? – kash Apr 09 '17 at 02:50
  • Yes, as long as it does the same thing if they ask to compare Ontario with Quebec as if they ask to compare Quebec with Ontario. This would happen if you sort the provinces alphabetically before querying the database, for example. The more normal thing to do would be to retrieve the Ontario data, then retrieve the Quebec data, and do the comparison in the local machine. In that case you only have the $2380$ pieces of data to look through. There are often trades between storage and running time. If you store the comparisons you save time at the cost of space. – Ross Millikan Apr 09 '17 at 03:08
0

Assuming options of locations for a and c are same.

For location a we have 14 options.

So for location we can't choose same location so we have 13 options now.

10 options for c and 17 options for d.

We have $14 \times 13 \times 10 \times 17$