Example #1
0
 def test_betai(self):
     np.random.seed(12345)
     for i in range(10):
         a = np.random.rand() * 5.
         b = np.random.rand() * 200.
         assert_equal(stats.betai(a, b, 0.), 0.)
         assert_equal(stats.betai(a, b, 1.), 1.)
         assert_equal(stats.mstats.betai(a, b, 0.), 0.)
         assert_equal(stats.mstats.betai(a, b, 1.), 1.)
         x = np.random.rand()
         assert_almost_equal(stats.betai(a, b, x),
                             stats.mstats.betai(a, b, x),
                             decimal=13)
Example #2
0
def check_sample_mean(sm, v, n, popmean):
    # from stats.stats.ttest_1samp(a, popmean):
    # Calculates the t-obtained for the independent samples T-test on ONE group
    # of scores a, given a population mean.
    #
    # Returns: t-value, two-tailed prob
    df = n-1
    svar = ((n-1)*v) / float(df)    # looks redundant
    t = (sm-popmean) / np.sqrt(svar*(1.0/n))
    prob = stats.betai(0.5*df, 0.5, df/(df+t*t))

    # return t,prob
    npt.assert_(prob > 0.01, 'mean fail, t,prob = %f, %f, m, sm=%f,%f' %
                (t, prob, popmean, sm))
Example #3
0
def check_sample_mean(sm, v, n, popmean):
    # from stats.stats.ttest_1samp(a, popmean):
    # Calculates the t-obtained for the independent samples T-test on ONE group
    # of scores a, given a population mean.
    #
    # Returns: t-value, two-tailed prob
    df = n - 1
    svar = ((n - 1) * v) / float(df)  # looks redundant
    t = (sm - popmean) / np.sqrt(svar * (1.0 / n))
    prob = stats.betai(0.5 * df, 0.5, df / (df + t * t))

    # return t,prob
    npt.assertTrue(
        prob > 0.01,
        'mean fail, t,prob = %f, %f, m, sm=%f,%f' % (t, prob, popmean, sm))