1

I am trying to minimize the sum of squares of a deviation from the mean applying the following:

Minimize[Sum[(Subscript[x, i] - μ)^2, {i, 0, n}], x]

It returns the expression, but I was expecting it to return an answer similar to the one below

Sum[Subscript[x, i], {i, 0, n}]/n

which is the sample mean.

Is this kind of minimization possible in Mathematica?

Kuba
  • 136,707
  • 13
  • 279
  • 740
arvind
  • 141
  • 5
  • 1
    You can do this if you giver an explicit value for n and Minimize the variable \[Mu] (x is not a variable in your formulation). – Daniel Lichtblau Jun 02 '14 at 20:56
  • 1
    Thanks a lot Dan..I tried the following Minimize[Sum[(Subscript[x, i] - \[Mu])^2, {i, 0, 10}], \[Mu]] and it works great. Thanks again – arvind Jun 02 '14 at 21:27
  • On a similar note how would you minimize the function with weights added Minimize[Sum[ Subscript[w, i]*(Subscript[x, i] - \[Mu])^2, {i, 0, 1}], \[Mu]]..so the answer is (Subscript[w, 0] Subscript[x, 0] + Subscript[w, 1] Subscript[x, 1])/(Subscript[w, 1] + Subscript[w, 2] ) and not the various values it gives – arvind Jun 02 '14 at 21:47
  • you may want to look at http://mathematica.stackexchange.com/a/16378/1089 – chris Jun 02 '14 at 23:09
  • Thanks but it specifies the rules of differentiation to solve a much more complex problem. I am trying to minimize a simple wieghted sum of deviation from the mean so that the solution returns the weighted average. Not sure what I am missing – arvind Jun 05 '14 at 06:16

1 Answers1

1

You can do this if you giver an explicit value for n and Minimize the variable μ (x is not a variable in your formulation).

– Daniel Lichtblau Jun 2 '14 at 20:56

Minimize[Sum[(Subscript[x, i] - μ)^2, {i, 0, 10}], μ]

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740