I’ve written some code that uses numpy’s array broadcasting logic and need to convert it to pseudocode. Basically, $win R^{T}$ and $betain R^{T times M}$. If you have the following code using numpy arrays:
T = 100
M = 10
w = np.ones(T) / T
b = np.ones((T, M))
x = (w * b).sum(axis=0)
Numpy will automatically broadcast w
to the correct axis of b
and x
becomes the weighted average of b
along axis=1
. How do I convert something like this into pseudocode?