Advent calendar value estimation

Can we estimate the value of an advent calendar from daily observations? In the following code we will consider the case of L'Ocittane Classic Beauty Advent Calendar.

#include <iostream> #include <vector> #include <map> #include <string> #include <numeric> #include <utility> using namespace std; double sum(const vector<double>& vals) { return accumulate(vals.begin(), vals.end(), 0.0); }; double avg(const vector<double>& vals) { return sum(vals) / vals.size(); }; int main() { double approx_value = 0; // we don't know t yet map<string, double> real_prices_dollar_per_ml = { {"Relaxing Shower Gel", 20.00/250}, {"Cherry Blossom Shower Gel", 20.00/250}, {"Shea Butter Hand Cream", 12.00/30}, {"Almond Delicious Soаp", 5.00/50}, {"Pivoine Flora Hand Cream", 12.00/30}, {"Repairing Shampoo", 24.00/300}, {"Ultra Rich Body Lotion", 12.00/75}, {"Verbena Soap with Leaves", 9.00/75}, {"Ultra Rich Shower Cream", 20.00/250}, {"Almond Delicious Hands", 24.00/75}, {"Almond Milk Concentrate", 50.00/200}, {"Cherry Blossom Shimmering Lotion", 29.00/250}, {"Verbena Coaling Hand Cream", 12.00/30}, {"Almond Shower Oil", 9.50/75}, {"Shea Butter Foot Cream", 29.00/150}, {"Arlesienne Perfumed Soap", 6.00/50}, {"Verbena Body Lotion", 29.00/250}, {"Revitalising Sugar Bath Cub", 4.00/33}, {"Citrus Verbena Shower Gel", 20.00/250}, {"Shea Butter Lip Balm", 9.00/4.5}, {"Arlesienne Eau de Toilette", 69/75}, {"Shea Light Comforting Cream", 29/50}, {"Repairing Conditioner", 29/50}, {"Repairing Conditioner", 24/250}, {"Shea Milk Extra-Gentle Soap", 12/250} }; vector<pair<string, double>> door_content_ml = { {"Relaxing Shower Gel", 35}, {"Cherry Blossom Shower Gel", 35}, {"Shea Butter Hand Cream", 10}, {"Almond Delicious Soаp", 50}, {"Pivoine Flora Hand Cream", 10}, {"Repairing Shampoo", 35}, {"Ultra Rich Body Lotion",30}, {"Verbena Soap with Leaves", 25}, {"Ultra Rich Shower Cream", 30}, {"Almond Delicious Hands", 10}, {"Almond Milk Concentrate", 20}, {"Cherry Blossom Shimmering Lotion", 35}, {"Verbena Coaling Hand Cream", 10}, {"Almond Shower Oil", 35}, {"Shea Butter Foot Cream", 10}, {"Arlesienne Perfumed Soap", 50}, {"Verbena Body Lotion", 30}, {"Revitalising Sugar Bath Cub", 35}, {"Citrus Verbena Shower Gel", 30}, {"Shea Butter Lip Balm", 3}, {"Arlesienne Eau de Toilette", 7.5}, {"Shea Light Comforting Cream", 5}, {"Repairing Conditioner", 35}, {"Shea Milk Extra-Gentle Soap", 25} }; for(const auto& prod : door_content_ml) { string product_name = prod.first; double product_ml = prod.second; approx_value += real_prices_dollar_per_ml[product_name] * product_ml; } cout << approx_value << endl; // 76.3491 dollar, announced value 87 British pound int days = 24; vector<double> daily_product_value_estimates, daily_total_value_estimates; for(const auto& prod : door_content_ml) { string product_name = prod.first; double product_ml = prod.second; daily_product_value_estimates.push_back(real_prices_dollar_per_ml[product_name] * product_ml); daily_total_value_estimates.push_back(avg(daily_product_value_estimates) * days); } for(double est : daily_total_value_estimates) { cout << est << " "; } // 67.2 67.2 76.8 87.6 89.28 85.6 89.8286 87.6 84.2667 83.52 86.8364 87.72 88.3569 89.6457 86.7627 90.34 89.9388 90.5988 88.862 91.6189 87.2561 83.2899 79.6686 76.3491 return 0; }

Suppose we don't know anything about this advent calendar in advance. Can we improve our estimates daily (as we open a new door) in guessing its value? The first door contains "Relaxing Shower Gel", 35ml. We see that the regular offer has a price of 20$/250ml. We calculate the value to be approx. 35*(20/250) = 2.8$. If that was the average price, then 24 doors * 2.8 would be 67.2$. We don't know anything more that that, so we wait for the next day. Then we see "Cherry Blossom Shower Gel", 35ml, having again the same price as the first product. Our estimate remains so far correct, so we don't update it. The third day starts with "Shea Butter Hand Cream", 10ml having a regular price of 12$ per 30ml. We estimate its price at 10*(12/30) = 4$. This changes our estimate. The average of the three days has now become (2.8 + 2.8 + 4) / 3 = 3.2, which when multiplied by 24 gives 76.8. At that point we don't know that we are actually close to the approximation we saw above. Here is a chart of our daily approximations and the target value.

Daily estimation of the advent calendar

We see that on most days our approximations are off by ≈10-15$, perhaps partially due to the low values of the items in the last few days (which we can't know in advance). We get closest to the approximated value only on the 3th of December. On the 24th of December we have all the knowledge to compute the approximate value (which we did at the start of the code). This approach is not without its downsides, so perhaps you know of a better one. If so, feel free to inform the wider community in your own unique way.

Happy estimates! :)