I am working on a small proof/demonstration of how the least squares method gives us the arithmetic mean.
Wolfram Language 14.0.0 Engine for Microsoft Windows (64-bit)
Copyright 1988-2023 Wolfram Research, Inc.
In[1]:= X := {x1, x2, x3}
In[2]:= Err[mu_] := X - mu
In[3]:= SSE[mu_] := Total[Err[mu]^2]
In[4]:= SSE'[mu]
Out[4]= -2 (-mu + x1) - 2 (-mu + x2) - 2 (-mu + x3)
In[5]:= Solve[SSE'[mu] == 0, mu]
x1 + x2 + x3
Out[5]= {{mu -> ------------}}
3
I would like a more general version where X
has an arbitrary length, X := {x1, x2, x3, ... , xn}
. Is there a way to express a vector of variable length? What I am ultimately looking for is mu -> (x1 + x2 + x3 + ... + xn) / n
.