# Inferring random variables from their sum

Suppose I have a large set of receipts that list the items I bought, but only list the total cost. One day I might have bought Milk, Butter, and Eggs. A different day I might have bought Bread, Milk, and Cereal. What I would like to do is fit a distribution of the price of each item.

To keep things simple, let's assume the price of each item is modeled by a Gaussian distribution (probably not ideal, since the prices can't be negative, but we'll start with this). And to make things even simpler, I assume that the distributions of Bread, Milk, etc. are independent from one another.

This means that $$\mu_{total} = \mu_{Bread} + \mu_{Eggs} + ...$$ and $$\sigma^2_{total} = \sigma^2_{Bread} + \sigma^2_{Eggs} + ...$$, which seems like it should make things straightforward. Here's what I've tried that didn't work:

• My first thought was to find MLE estimates for each of the $$\mu_{Bread}$$, etc. However, when I take the partial derivatives of the log-likelihood function, I get a function that also depends on all the other $$\mu_{Eggs}, \mu_{Milk}$$, etc.

• That made me think that maybe I should use EM, but I can't think of what would be the latent variable here.

• I considered stochastic gradient descent, but I'm worried that the space will be non-convex.

• I've also thought about using a Gaussian mixture model, but that doesn't seem appropriate since each receipt doesn't come from a single sub-population.

What would be a good way to infer the $$\mu$$ and $$\sigma$$ for each individual item?

• If on the receipt you have the total cost and the number of items of each type, you should be able to regress the cost on the item counts to determine the prices. – jsk Jun 7 at 22:33
• ... as long as there's sufficient data points for it to be estimable, this should work. If the prices are fixed constants you'd get exact values; if they vary randomly (a dubious assumption for groceries) there's some complications to deal with (the prices will be heteroskedastic) – Glen_b Jun 8 at 3:36
• @jsk: If you add this as an answer, I can mark it as accepted. – Ben Jun 8 at 22:13

$$Y = \beta_0 + \beta_{bread}*X_{bread} + \beta_{eggs}*X_{eggs} + \beta_{milk}*X_{milk} + \epsilon$$
where $$X_{item}$$ is the number of that item in the purchase, and use regression to estimate the parameters. In this model, $$\beta_{item}$$ represents the average cost of that item across the population.