<<   >>

2. A Short Average

x⌹x=x

If x is a vector, x⌹x=x is a shorter phrase for the average of vector x . Note that + / ⌿ ÷ ⍴ ≢ are not used. The idea originated with Timo Seppälä at APL82 [14]. To see why it works, start with the definition

  y⌹x ←→ (⌹(+⍉x)+.×x)+.×(+⍉x)+.×y

which defines the rectangular case in terms of the square case.

x⌹x=x
x⌹w w←x=x
(⌹(+⍉w)+.×w)+.×(+⍉w)+.×x   definition of
(⌹(⍉w)+.×w)+.×(⍉w)+.×x w is non-complex
(÷≢x)+.×w+.×x w is (≢x)⍴1; w+.×w is ≢x
(÷≢x)+.×+⌿x ((≢x)⍴1)+.×x ←→ +⌿x
(÷≢x)×+⌿x LHS and RHS of +.× are scalars
(+⌿x)÷≢x
          QED

Alternatively, y⌹x computes a linear regression for y wherein the constant term is the mean of y ; that is, the best least square “fit” of a vector by a single number, is its mean.