This is a combinatorial counting problem I'm trying to solve just for my own curiosity, but the obvious approach (in my mind) balloons into a multi-dimensional nightmare very quickly.
Say you work for a service, and customers can give you a rating. The rating scale is 1..5, with 5 as best. They have 24 hours to rate you, and after that they can't. You don't get to see the individual ratings, but you can see the average rating over the past 24 hours. You only know you got somewhere between 1 and 'n' ratings that resulted in the current average, where 'n' is the number of customers you've had in the past 24 hours. (Some people rate immediately, some wait a bit, and some never get around to it.)
Here's the problem: given an average rating and the maximum number of possible ratings (ie., customers) over the past 24 hours, what are the different combinations of ratings that could have been given that will produce that exact average rating value? Also, historically speaking, it's very rare for 100% of customers to give ratings; the average is around 60%-70%.
If it helps, assume there won't be more than 20 possible ratings in any 24 hour period. Also, assume the average never drops below 4.0 -- that is, most ratings are 5's. The question is, what's the possible distribution of non-5 ratings for any given average?
Example: you had 10 customers in the past 24 hours, and you have an average rating of 4.67. What are the possible ratings that could have produced that average? (I got that average with three ratings of: 5, 5, and 4.) The question is, how can one discover all possible rating combinations that produce a 4.67 average with a max of 10 possible ratings?
Perhaps I should add that the norm is 5. So 5s pull the average up, while everything else pulls it down.
The rating is always given as a floating point number with at most two decimals: 4.xx