def test_median_ci(): alpha = np.ones((2, 10)) m1 = np.ones(2) m0 = np.ones(10) mout1, ci_1 = pycircstat.median(alpha, axis=1, ci=.8) mout0, ci_0 = pycircstat.median(alpha, axis=0, ci=.8) moutall, ci_all = pycircstat.median(alpha, axis=0, ci=.8) assert_allclose(mout1, m1) assert_allclose(mout0, m0) assert_allclose(moutall, 1.) assert_allclose(ci_0.lower, m0) assert_allclose(ci_0.upper, m0) assert_allclose(ci_1.lower, m1) assert_allclose(ci_1.upper, m1) assert_allclose(ci_all.lower, 1.) assert_allclose(ci_all.upper, 1.)
def test_median(): alpha = np.array([ [3.73153000, 1.63904879, 4.03175622, 3.90422402, 4.61029613, 4.04117818, 5.79313473, 5.50863002, 5.81530225, 2.44973903], [2.12868554, 0.09073566, 0.05581025, 5.10673712, 1.68712454, 3.72915575, 4.45439608, 4.70694685, 3.58470730, 2.49742028] ]) m0 = np.array([2.93010777, 0.86489223, -1.09780942, -1.77770474, -3.13447497, -2.39801834, -1.15941990, -1.17539688, -1.58318053, 2.47357966]) % (2 * np.pi) m1 = np.array([-2.24671810, -1.24910966]) % (2 * np.pi) m11 = np.array([-2.24200713, -1.82878923]) % (2 * np.pi) mall = -2.2467 % (2 * np.pi) assert_allclose(pycircstat.median(alpha, axis=1), m1) assert_allclose(pycircstat.median(alpha[:, :-1], axis=1), m11) assert_allclose(pycircstat.median(alpha, axis=0), m0) assert_allclose(pycircstat.median(alpha), mall, atol=1e-4)