Мінімізація суми абсолютного відхилення (


15

У мене є набір даних і я хочу знайти параметр m таким, щоб він мінімізував суму k i = 1 | m - x i | . тобтоx1,x2,,xkm

i=1k|mxi|.

minmi=1k|mxi|.

2
Не могли б ви трохи допрацювати?
Джефф Оксберрі

У такому випадку, чи не було б тоді рішенням серединою між максимальним і мінімальним значеннями?
Павло

@Paul медіана може звести до мінімуму суму, але хоче знати, як це можна зробити аналітично, особливо з мінімізацією l1
май

@kadu правильно, медіана - це рішення. Обчислення аналітичної медіани тривіально; просто сортуйте, а потім візьміть середнє значення.
Девід Кетчесон

Відповіді:


22

Напевно, ви просите доказ того, що медіана вирішує проблему? Ну, це можна зробити так:

Ціль є кусочно лінійною і, отже, диференційованою, за винятком точок . Який нахил цілі є деякою точкою m x i ? Ну, нахил - це сума схилів відображень m | m - x j | і це або + 1 (для m > x j ), або - 1 (для m < x j ). Отже, нахил вказує, на скільки х i менших mm=ximxim|mxj|+1m>xj1m<xjximxim (for and even number of xi's). If there is an odd number of xi's then the slope is 1 left of the "middlest" one and +1 right of it, hence the middlest one is the minimum.


16

Узагальнення цієї задачі на множинні виміри називається геометричною серединною задачею . Як вказує Девід, медіана - це рішення для одноденного випадку; там ви можете використовувати алгоритми вибору середнього пошуку , які є більш ефективними, ніж сортування. Сорти єО(нжурналн) тоді як алгоритми відбору є О(н); сортування є більш ефективними лише в тому випадку, якщо потрібно кілька виборів, і в цьому випадку ви можете сортувати (дорого) один раз, а потім повторно вибирати зі списку відсортованих.

Посилання на геометричну серединну задачу згадує рішення для багатовимірних випадків.


6

The explicit solution in terms of the median is correct, but in response to a comment by mayenew, here's another approach.

It is well-known that 1 minimization problems generally, and the posted problem in particular, can be solved by linear programming.

The following LP formulation will do for the given exercise with unknowns zi,m:

minzi
such that:
zimxi
zixim

Clearly zi must equal |xim| at the minimum, so this asks the sum of absolute values of errors to be minimized.


2

The over-powered convex analysis way to show this is just take subgradients. In fact this is equivalent to the reasoning used in some of the other answers involving slopes.

The optimization problem is convex (because the objective is convex and there are no constraints.) Also, the subgradient of |mxi| is

-1 if m<xi

[-1,1] if m=xi

+1 if m>xi.

Since a convex function is minimized if and only if it's subgradient contains zero, and the subgradient of a sum of convex functions is the (set) sum of the subgradients, you get that 0 is in the subgradient if and only if m is the median of x1,xk.


0

We're basically after:

argminmi=1N|mxi|

One should notice that d|x|dx=sign(x) (Being more rigorous would say it is a Sub Gradient of the non smooth L1 Norm function).
Hence, deriving the sum above yields i=1Nsign(mxi).
This equals to zero only when the number of positive items equals the number of negative which happens when m=median{x1,x2,,xN}.

One should notice that the median of a discrete group is not uniquely defined.
Moreover, it is not necessarily an item within the group.

Використовуючи наш веб-сайт, ви визнаєте, що прочитали та зрозуміли наші Політику щодо файлів cookie та Політику конфіденційності.
Licensed under cc by-sa 3.0 with attribution required.