I am trying to compute a weighted average with the code:
def estimate(particles, weights):
mean = np.average(particles, axis=particles[:, :], weights=weights)
var = np.average((particles - mean)**2, weights, axis=0)
return mean, var
However, I cannot seem to get my axis correct. The shape of my particles is (100,2) and the shape of my weights is (100,), and I would like to do the averaging vertically, so adding particles[0][0] with particles[1][0].... particles[99][0] and the same with particles[0][1],... particles[99][1]. How do I create an axis to do this?