Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
Created June 18, 2019 12:05
Show Gist options
  • Save thomasaarholt/0cabea3fbd05ec77287fe7aa19aa534d to your computer and use it in GitHub Desktop.
Save thomasaarholt/0cabea3fbd05ec77287fe7aa19aa534d to your computer and use it in GitHub Desktop.
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