Thinking of weighted averages in terms of projections

575 Views Asked by At

I have 3D gridded oceanographic data for a variety of properties and I'm computing depth weighted averages (the gridding is irregular, but the dataset comes with the gridding data which can be called easily).

Let's say that I have a segment of ocean (for simplicity let's say I've already averaged in longitude and now have latitude, X, versus depth, Z), and I want to find the weighted depth average temperature, for example. If I'm not mistaken, this should be the each Z level of my X by Z grid multiplied by the corresponding Z cell value. Then I would sum over the Z dimension and then divide by the total depth (the sum of the values of Z).

This made me think that if I thought of X vs Z as a matrix, I could think of this as

$\frac{{X}^T\vec{z} }{\sum_i{{z_i}}}$ (Right?)

But this looks a lot like a projection of the columns of $X$ onto $\vec{z}$, but with $\sum{z_i}$ instead of $\sum{z_i^2}$. Is there a way to think of this weighted average as a projection? Is there a different sense of norm I could use? This doesn't change my answer (unless my answer is wrong :/) but I would like to have a better way to relate my linear algebra knowledge to practical applications. Feel free to wax poetic about this.

1

There are 1 best solutions below

2
On

From your description, it looks like both $X$ and $\vec{z}$ are vectors. So instead of talking about the columns of $\vec{z}$, it makes more sense to talk about its components. I'll use bold notation for both $\mathbf{x}$ and $\mathbf{z}$ as vectors When taking a weighed average, you are taking a weighted combination of the components of the $n$-dimensional vector $\mathbf{x}$ (the measurements) we can write it like this

$$ w_{1} x_{1} + w_{2} x_{2} + \ldots + w_{n} x_{n} $$

For this to be an average we need

$$ \sum_{k=1}^{n} w_{k} = 1 $$

For the ordinary mean average we use

$$ w_{1} = \ldots = w_{n} = \frac{1}{n} $$

If you use the depth data to weight the components of $\mathbf{x}$, you are using

$$ w_{k} = \frac{z_{k}}{Z} $$

where $Z$ is the sum of all components in $\mathbf{z}$ - this ensures that the sum of the $w_{k}$'s equals one.

You can think of this as a kind of projection, if we consider the result of dividing the vector $\mathbf{z}$ by the total of its components: $$ \mathbf{v} = \frac{\mathbf{z}}{Z} = \left( \frac{z_{1}}{Z} , \ldots , \frac{z_{n}}{Z} \right)^{T} $$

The weighted average is then $\mathbf{x}^{T} \mathbf{v}$. We can normalise the vector $\mathbf{v}$, so that it has unit length in $\mathbb{R}^{n}$, by dividing it by the Euclidean norm $v = |\mathbf{v}| = \sqrt{v_{1}^{2} + \ldots + v_{n}^{2}}$

$$ \mathbf{u} = \frac{\mathbf{v}}{v} $$

Now the weighted average is $\mathbf{x}^{T} \mathbf{v} = v \mathbf{x}^{T} \mathbf{u}$, so it is $v$ times the component of $\mathbf{x}$ in the direction of the $n$-vector $\mathbf{u}$. I.e. it is a scaled projection in $\mathbb{R}^{n}$