def check_1D_list(self): a = (1,2,3,4) actual= stats.gmean(a) desired = power(1*2*3*4,1./4.) assert_almost_equal(desired,actual,decimal=14) desired1 = stats.gmean(a,axis=-1) assert_almost_equal(desired1,actual,decimal=14)
def check_1D_array(self): a = array((1,2,3,4), float32) actual= stats.gmean(a) desired = power(1*2*3*4,1./4.) assert_almost_equal(desired,actual,decimal=7) desired1 = stats.gmean(a,axis=-1) assert_almost_equal(desired1,actual,decimal=7)
def check_2D_array_default(self): a = array(((1,2,3,4), (1,2,3,4), (1,2,3,4))) actual= stats.gmean(a) desired = array((1,2,3,4)) assert_array_almost_equal(desired,actual,decimal=14) desired1 = stats.gmean(a,axis=0) assert_array_almost_equal(desired1,actual,decimal=14)
def check_2D_array_dim1(self): a = array(((1,2,3,4), (1,2,3,4), (1,2,3,4))) actual= stats.gmean(a, axis=1) v = power(1*2*3*4,1./4.) desired = array((v,v,v)) assert_array_almost_equal(desired,actual,decimal=14)
def calc(x, conf): size = len(x) sum = stats.sum(x) av = stats.average(sum, size) gm = stats.gmean(x) v = stats.var(sum, stats.sqsum(x), size) med = stats.median(x) if v != 'error': sd = stats.stdv1(v) c = stats.conf(float(conf), sd, size) else: sd = 'error' c = 'none' return av, gm, v, sd, c, med