I have an n-dimensional ndarray z0
, and a 1-dimensional ndarray za
. The sizes don't correspond to each other in any way. I'd like to be able to create a new n+1-dimensional array, z
, where z[i]=z0+za[i]
. Is there some simple way to do this with broadcasting?
This is not equivalent to this question. If z0
is 2D, this can be easily achieved as follows:
z0[np.newaxis]+norm.ppf(alphas)[:,None]
However, I need to be able to do this regardless of z0's dimensionality, and so simply adding the correct number of None
or np.newaxis
terms won't work.