1

In order to write a test case for a program, I want to calculate the weighted average based on weights $w_i$ and values $X_i$.

Weighted average $W$ is given as

$$ W = \frac{\sum_{i=1}^n w_i*X_i}{\sum_{i=1}^n w_i} $$

I need three distinct weights, $w_1$, $w_2$ and $w_3$ and the sum of these weights must be at least 50.

Is there a solution ${X_i}$ for $w_1=11$, $w_2=22$, $w_3 = 66$ such that all $W, X_i \in \mathbb{N}$?

I'm happy to use any other values for the weights if the given ones in my example have no solution.

TMOTTM
  • 177

1 Answers1

2

Taking $n = 3$, you want

$$W = \frac{11X_1 + 22 X_2 + 66 X_3}{11+22+66} = \frac{11(X_1 + 2X_2 + 6X_3)}{99} = \frac{X_1 + 2X_2 + 6 X_3}{9}$$

to be an integer. Of course there are infinitely many solutions $X_1, X_2,X_3 \in \mathbb N$ to your problem. You may take $X_1, X_2$ to be any positive integers which are divisible by $9$, and $X_3$ to be any positive integer which is divisible by $3$.

D_S
  • 33,891