Skip to content

Instantly share code, notes, and snippets.

@lmassaron
Created March 31, 2019 08:40
Show Gist options
  • Select an option

  • Save lmassaron/5e5ae72fed02d7b50a98007c03f6b936 to your computer and use it in GitHub Desktop.

Select an option

Save lmassaron/5e5ae72fed02d7b50a98007c03f6b936 to your computer and use it in GitHub Desktop.
Chauvenet's criterion
# In statistical theory, Chauvenet's criterion (named for William Chauvenet[1]) is a means of assessing whether
# one piece of experimental data — an outlier — from a set of observations, is likely to be spurious.
# https://en.wikipedia.org/wiki/Chauvenet%27s_criterion
def chauvenet(array):
mean = array.mean() # Mean of incoming array
stdv = array.std() # Standard deviation
N = len(array) # Lenght of incoming array
criterion = 1.0/(2*N) # Chauvenet's criterion
d = abs(array-mean)/stdv # Distance of a value to mean in stdv's
prob = erfc(d) # Area normal dist.
return prob < criterion # Use boolean array outside this function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment