How to minimize a summation function

76 Views Asked by At

My question is: How do we minimize a function like this with find a constant number for x?

in another word, we have a set and "i" is a member of that set and we should find a constant number as x to minimize that function My problem function

1

There are 1 best solutions below

0
On BEST ANSWER

As @Yves says, take the median. Proof: $$f(x)=\sum_i |i-x|=\sum_{i \geqslant x} (i-x) + \sum_{i < x} (x-i) $$ $$f'(x)=\sum_{i \geqslant x} (-1) + \sum_{i < x} (+1) $$ which is the number of data points less than $x$ LESS the number of data points greater than $x$. To minimize $f(x)$ we want its derivative to be zero, which gives us the median.