Finding a hash function that calculates average of an item in a stream of tuples

So, I have a stream of tuples coming in for example [country, state, person], where state and person are unique items. Now I have to find : 1. for each country, I have to estimate average number of persons in a state. How do I design a sketch that uses a hash function that does this with a minimum memory storage.

• Welcome to Cryptography. Your question is not clear, or at least your intention that makes your question is not answerable. Does the tuple come with the hash values to you? The hash values are only around 256-bit and once you increment one can clear the memory. Or actually, you want to decrease the data sent through the stream? – kelalaka Feb 26 at 8:37
• @kelalaka The tuples do not come with a hash value. I am new to this topic and I am trying to learn so my question might have been a bit confusing. What my question actually is: I have a stream of data coming in the form of tuple [Country, state, person]. now on this stream of data, I want to perform the operation of calculating the average number of people in the state. I though of doing it by taking the Key as [Country, State]. for every unique tuple, a hash function updates a bucket which contains the count. – deepthi sai Feb 27 at 0:21
• [Continuation] For Eg: If I have a tuple [USA, Ohio, person1], then when this comes in bucket 2 is updated, and every time the tuple with USA and Ohio comes in, this count keeps increasing. this would give me the total number of people who are from USA-Ohio, but I am confused on how to find the average of it i.e the average number of people who belong to [USA,Ohio]. I hope this cleared up things a bit. – deepthi sai Feb 27 at 0:26