The script below is not doing what I want. The script needs to calculate the mean and the standard deviation value in Gamma_CPS then for all values below the mean assign a "0" value,
1 standard deviation above mean assign an "1"
2 standard deviation above mean assign an "2" etc up to 5.
Can someone tell me why it assigns everything a value of 5???
# val: inout value - mu, sig: normal dist params,
# inc: std increments (def: 1)
# cat: category limit (def: virtually unlimited)
# Call the method with 'val' as the field and other params in desired config.
def z_score(val, mu, sigma, inc=1.0, cat=5):
return (0 if val < mu else min(cat, int(abs(val-mu)/float(sigma)/inc)+1))