Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import numpy as np
x = np.array([500, 500, 500, 1000, 1000, 1000, 1500])
y = np.array([1,2,3,4,5,6,7])
data = np.stack([x,y]).T
means = []
stds = []
for xi in np.unique(data[:,0]):
mask = data[:,0] == xi
vals = data[:,1][mask]
means.append(vals.mean())
stds.append(vals.std())
means = np.array(means)
stds = np.array(stds)
means
stds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.