Skip to content

Instantly share code, notes, and snippets.

@shotahorii
Last active January 2, 2016 06:39
Show Gist options
  • Save shotahorii/8265168 to your computer and use it in GitHub Desktop.
Save shotahorii/8265168 to your computer and use it in GitHub Desktop.
[statistics] Standardisation
#python version 3.3.3
#needs averages.py(https://gist.github.com/shotahorii/8206127)
#and dispersion.py(https://gist.github.com/shotahorii/8207631)
import dispersion as disp
#transform x -> ax + b
#l: list of numbers, a,b: numbers
def transform(l,a,b):
return [a*l[i]+b for i in range(len(l))]
#standardise the data
#l: list of numbers
def standardise(l):
return transform(l,1/disp.stdDev(l),-1/disp.coef(l))
#calculate tScore
#l: list of numbers
def tScore(l):
standardised = standardise(l)
return [10*standardised[i]+50 for i in range(len(l))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment