5 star average rating which also considers number of users rated Consider there are 2 products which has 5-star ratings from users. The first product gets millions of ratings from users and gets an average rating of 4 while the second product only has 10-100 reviews with an average rating of 4
Product A:  millions of ratings with average 4
Product B: only 10 to 1000 ratings with average 4
I need my system to consider product A better as compared to B as it is rated by more users with the same average rating. Can we arrive at a fixed measure that differentiates the two products based on the number of users who rated it? Is there a concrete solution/formula?
 A: There is no single accepted way to deal with this. The obvious trade-off is average rating vs precision of the rating as reflected by their number. Hence, one might prefer a product whose average rating is slightly lower, but it was rated considerably more often, thus providing more confidence that the average rating is reasonable.
One solution to resolve this trade-off is the use the lower range of the 95% confidence interval of the rating. For each product $i$, this can be computed with the following expression:
$$\text{Score}_i=\bar{x}_i-1.96*\frac{\sigma_i}{\sqrt{n_i}},$$
where $\bar{x}_i$ is the mean rating of product $i$, $\sigma_i$ is the standard deviation, and $n_i$ is the number of ratings for product $i$.
Notice that, if $n_i$ gets very large, the score converges to the average rating $\bar{x}_i$. For products with very few ratings ($n_i$ small), the score is smaller than the average rating, and it is smaller the fewer ratings it has and the more these ratings disagree (as measured by the standard deviation $\sigma_i$). Thus, the score combines the average rating and the number of ratings into a single number, along which you can rank products. This also means that a product with a lower average rating might be better ranked, because it has more ratings and you are thus more confident that the average rating is solid.
Finally, why the factor 1.96? Well, for your purposes you could change this factor to a larger or smaller number, thus punishing products with fewer ratings less or more. This number is the appropriate one if you compute a 95% confidence interval under the assumption that your ratings are normally distributed. But since your are not interested in statistical testing, the exact factor is not that important - this is the usual one from statistics.
