How to to find the closest match to a unknown component from variable of known components?

24 Views Asked by At

For example, a sweet shop has three jars of sweets:

Jar 1: 2 blue sweets, 1 red sweets and 5 green sweets

Jar 2: 1 blue sweets, 5 red sweets and 3 green sweets

Jar 3: 8 blue sweets, 1 red sweet and 2 green sweets

The price for each jar is as follows:

Jar 1 is £5 Jar 2 is £10 Jar 3 is £15

Know imagine I have a jar of my own making and want to estimate the price of that jar.

The jar I have contains 2 blues sweets, 3 red sweets and 1 green sweets.

Is there a formula by which we can estimate the price. I’m hoping that this formula can derive the price which is equal to one of the above mentioned prices (I.e. it is only equal to 5,10 or 15 pounds and no other price) based only on the closest matching Jar in terms of sweet components.

1

There are 1 best solutions below

0
On

Call the price of blue sweets $b$, the price of red sweets $r$, and the price of green sweets $g$. Then, you have the following set of equations you need to solve in order to determine the price of each of the sweets: \begin{align} 2b + r + 5g = 5 \quad &\text{(Jar 1)}, \\ b + 5r + 3g = 10 \quad &\text{(Jar 2)}, \\ 8b + r + 2g = 15 \quad &\text{(Jar 3)}. \end{align} Once you have solved for $b$, $r$, and $g$. You can calculate the price of any jar you'd like to construct.