I Convert 2 variables into 1 representative variable

I need help to convert 2 variables A,B into 1 representative variable C, which is used to filter A,B:

Below is an example with C=A+B, which makes Set 2 the highest value:
Set 1: A=65, B=75, C=140;
Set 2: A=50, B=100, C=150;
Set 3: A=54, B=90, C=144;
Set 4: A=72, B=72, C=144;
Set 5: A=71, B=73, C=144;
Set 6: A=71, B=71, C=142;

But I want either Set 4 or 5, which has *both* A and B being closer to 100, and also a high A+B value.

If you know/understand computer code:
if(C>previousC) isBestSet=SetNumber;

I do not care if C is a big or small number, meaning I do not care if I need to pick the biggest or smallest C.
Thanks
 
32,580
4,310
I need help to convert 2 variables A,B into 1 representative variable C, which is used to filter A,B:

Below is an example with C=A+B, which makes Set 2 the highest value:
Set 1: A=65, B=75, C=140;
Set 2: A=50, B=100, C=150;
Set 3: A=54, B=90, C=144;
Set 4: A=72, B=72, C=144;
Set 5: A=71, B=73, C=144;
Set 6: A=71, B=71, C=142;
I'm not sure what adding A and B does for you, but it seems like you want to minimize the distance from a point (A, B) to the point (100, 100)
For set 4 (the point (72, 72) ), the distance is ##\sqrt{1568}##.
For set 5 (the point (71, 73) ), the distance is ##\sqrt{1570}##.
To calculate the distance of a point (A, B) to (100, 100), the formula is ##d = \sqrt{(100 - A)^2 + (100 - B)^2}##.
1plus1is10 said:
But I want either Set 4 or 5, which has *both* A and B being closer to 100, and also a high A+B value.

If you know/understand computer code:
if(C>previousC) isBestSet=SetNumber;

I do not care if C is a big or small number, meaning I do not care if I need to pick the biggest or smallest C.
Thanks
 
Wow. Perfect. Thank you very much.

I Googled: "minimize the distance from a point"
I see that this technique is actually the Pythagorean theorem, which leads me to another question:

Sometimes my Sets have 3 variables instead of 2.
Is it safe to *assume* that I simply tack on another: + (100-3rdVar)^2
(i.e. since there is no real need for me to preform the final square root)

Thanks again.
 
32,580
4,310
Wow. Perfect. Thank you very much.

I Googled: "minimize the distance from a point"
I see that this technique is actually the Pythagorean theorem, which leads me to another question:

Sometimes my Sets have 3 variables instead of 2.
Is it safe to *assume* that I simply tack on another: + (100-3rdVar)^2
(i.e. since there is no real need for me to preform the final square root)

Thanks again.
Yes, distance in three dimensions is ##d = \sqrt{(x_1 - y_1)^2 + (x_2 - y_2)^2 + (x_3 - y_3)^2}##. And if ##(x_1, x_2, x_3)## and ##(y_1, y_2, y_3)## are the minimum distance apart, the square of their distance, ##d^2##, will also be at a minimum.
 
33,035
8,809
You can also take the largest difference to 100, C=max(100-A, 100-B). There are many functions, the best for you depends on what exactly you want to prefer over what.

All methods discussed can be extended to 3 variables easily.
 
Excellent.
Thanks again Mark!

mfb,
Thanks anyway, but Mark nailed it for me right on the head.
 

Want to reply to this thread?

"Convert 2 variables into 1 representative variable" You must log in or register to reply here.

Related Threads for: Convert 2 variables into 1 representative variable

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving

Hot Threads

Top