Counting Occurrences in a List

I’m still working on the Birthday Paradox activity and struggling with a challenge. In the version posted:

The results table can contain duplicates if more than two people have the same birthday

A better approach might be to remove such duplicates and add a third column identifying the number of people with that birthday. That means for each distinct match found counting the number of occurrences of that date in the full list of dates (held in single integer format). My problem is finding a reasonable way to create this list of occurrences. I can see how it can be done with each match individually but is there a way to use a single expression in the Graphing Calculator to achieve the same effect? Thanks in advance!

It looks like if you make a list of points and the unique( ) function, it will sort out as you desire.

(I threw in a duplicate x-coordinate just to be sure it was checking both coordinates of the points.)

“It looks like if you make a list of points and the unique( ) function, it will sort out as you desire.”

Thanks Daniel, I didn’t know about the unique() function. I’ve updated the activity linked to this thread to use it but I don’t see how it can help with the completion of the occurrences table? What I think I need is a function to count occurrences of the form “count (x,A)” returning the number of occurrences of the value x in the list A. Do you know of a way to achieve that effect?

I’ve also modified the activity to display the results in a graph but still need to find a way to show cases where more than two people have the same birthday.

I adapted another graph I had for frequency counts with a list of numbers.

1 Like

In addition to Daniel’s method, if A contains all values and A_reduced contains the identified duplicates, then

F_req = [ length( A[A=i] ) for i=A_reduced ]

will give you a frequency list that corresponds with A_reduced.

1 Like

It won’t allow you to check the equality of points, thus use of distance( ).

Thanks @Daniel_Grubbs & @pirsquared, you have given me lots of new material that I’d like to understand as well as use. I’m not working with points, as the day and month values of each birthday are combined to produce a single list of integers so that may simplify matters. I’ll report back after experimenting.

1 Like

After experimenting, I now understand the suggestions from @Daniel_Grubbs and @pirsquared, and see how either could be used to solve the problem posted. The suggestion from @pirsquared is the best fit, however, so that is the one I’ve adopted. Both suggestions have moved on my knowledge of Desmos, so again thanks!

Apart from tidying, that probably completes the activity unless someone has a suggestion for improving the ‘heavy handed’ table construction on the second screen, as posted in a separate thread.

1 Like