You will write functions that read a two-way table stored as a list of rows: a conditional probability, an expected count, and a test for independence.
The idea. table[i][j] is the count in row i and column j. Given column j, the share of row i is table[i][j] divided by the column total. If the rows and columns were independent, each count would be the row total times the column total, divided by the grand total.
Your tasks.
given_column(table, i, j). Return the probability of row i, given column j.expected(table, i, j). Return the count expected in row i and column j if the two answers were independent.independent(table). Return True when every count equals its expected count.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…