コード例 #1
0
def test_t_1samp():
    "Test 1-sample t-test"
    ds = datasets.get_uts(True)

    y = ds['uts'].x
    t = scipy.stats.ttest_1samp(y, 0, 0)[0]
    assert_allclose(stats.t_1samp(y), t, 10)

    y = ds['utsnd'].x
    t = scipy.stats.ttest_1samp(y, 0, 0)[0]
    assert_allclose(stats.t_1samp(y), t, 10)
コード例 #2
0
def test_t_1samp():
    "Test 1-sample t-test"
    ds = datasets.get_uts(True)

    y = ds['uts'].x
    t = scipy.stats.ttest_1samp(y, 0, 0)[0]
    assert_allclose(stats.t_1samp(y), t, 10)

    y = ds['utsnd'].x
    t = scipy.stats.ttest_1samp(y, 0, 0)[0]
    assert_allclose(stats.t_1samp(y), t, 10)
コード例 #3
0
    def __init__(self,
                 y,
                 x,
                 c1=None,
                 c0=None,
                 match=None,
                 sub=None,
                 ds=None,
                 tail=0):
        if match is None:
            raise TypeError("The `match` argument needs to be specified for a "
                            "related measures t-test.")
        ct = Celltable(y, x, match, sub, cat=(c1, c0), ds=ds, coercion=asvar)
        c1, c0 = ct.cat
        if not ct.all_within:
            raise ValueError(
                "conditions %r and %r do not have the same values "
                "on %s" % (c1, c0, dataobj_repr(ct.match)))

        n = len(ct.y) // 2
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.y)
        self._x = dataobj_repr(ct.x)
        self.c1_mean = ct.y[:n].mean()
        self.c0_mean = ct.y[n:].mean()
        self.diff = ct.y[:n] - ct.y[n:]
        self.df = n - 1
        self.t = stats.t_1samp(self.diff.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
        self._c1 = c1
        self._c0 = c0
コード例 #4
0
ファイル: test.py プロジェクト: mhellb/Eelbrain
 def __init__(
     self,
     y: VarArg,
     x: Union[CategorialArg, VarArg],
     c1: CellArg = None,
     c0: CellArg = None,
     match: CategorialArg = None,
     sub: IndexArg = None,
     ds: Dataset = None,
     tail: int = 0,
 ):
     y1, y0, c1, c0, match, n, x_name, c1_name, c0_name = _related_measures_args(
         y, x, c1, c0, match, ds, sub)
     if n <= 2:
         raise ValueError("Not enough observations for t-test (n=%i)" % n)
     self._y = dataobj_repr(y1)
     self._x = x_name
     self._c1 = c1
     self._c0 = c0
     self.c1_mean = y1.mean()
     self.c0_mean = y0.mean()
     self.difference = y1 - y0
     t = stats.t_1samp(self.difference.x[:, None])[0]
     TTest.__init__(self, t, n - 1, tail)
     self._match = dataobj_repr(match, True)
コード例 #5
0
ファイル: test.py プロジェクト: christianbrodbeck/Eelbrain
    def __init__(self, y, x, c1=None, c0=None, match=None, sub=None, ds=None,
                 tail=0):
        if match is None:
            assert c1 is None and c0 is None
            y1 = asvar(y, sub, ds)
            n = len(y1)
            y0 = asvar(x, sub, ds, n)
            self._y = dataobj_repr(y1)
            self._x = dataobj_repr(y0)
        else:
            ct = Celltable(y, x, match, sub, cat=(c1, c0), ds=ds, coercion=asvar)
            c1, c0 = ct.cat
            if not ct.all_within:
                raise ValueError("conditions %r and %r do not have the same values "
                                 "on %s" % (c1, c0, dataobj_repr(ct.match)))

            n = len(ct.y) // 2
            self._y = dataobj_repr(ct.y)
            self._x = dataobj_repr(ct.x)
            y1 = ct.y[:n]
            y0 = ct.y[n:]
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self.c1_mean = y1.mean()
        self.c0_mean = y0.mean()
        self.difference = y1 - y0
        t = stats.t_1samp(self.difference.x[:, None])[0]
        TTest.__init__(self, t, n - 1, tail)
        self._match = None if match is None else dataobj_repr(match)
        self._c1 = c1
        self._c0 = c0
コード例 #6
0
ファイル: test.py プロジェクト: christianbrodbeck/Eelbrain
    def __init__(self, y, match=None, sub=None, ds=None, tail=0):
        ct = Celltable(y, None, match, sub, ds=ds, coercion=asvar)
        n = len(ct.y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self.mean = ct.y.mean()
        self._y = dataobj_repr(ct.y)
        t = stats.t_1samp(ct.y.x[:, None])[0]
        TTest.__init__(self, t, n - 1, tail)
コード例 #7
0
    def __init__(self, y, match=None, sub=None, ds=None, tail=0):
        ct = Celltable(y, None, match, sub, ds=ds, coercion=asvar)
        n = len(ct.y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.y)
        self.df = n - 1
        self.t = stats.t_1samp(ct.y.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
コード例 #8
0
    def __init__(self, y, match=None, sub=None, ds=None, tail=0):
        ct = Celltable(y, None, match, sub, ds=ds, coercion=asvar)
        n = len(ct.Y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.Y)
        self.df = n - 1
        self.t = stats.t_1samp(ct.Y.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
コード例 #9
0
ファイル: test.py プロジェクト: mhellb/Eelbrain
    def __init__(
        self,
        y: VarArg,
        match: CategorialArg = None,
        sub: IndexArg = None,
        ds: Dataset = None,
        tail: int = 0,
    ):
        ct = Celltable(y, None, match, sub, ds=ds, coercion=asvar)
        n = len(ct.y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self.mean = ct.y.mean()
        self._y = dataobj_repr(ct.y)
        t = stats.t_1samp(ct.y.x[:, None])[0]
        TTest.__init__(self, t, n - 1, tail)
コード例 #10
0
    def __init__(self, y, x, c1=None, c0=None, match=None, sub=None, ds=None,
                 tail=0):
        if match is None:
            raise TypeError("The `match` argument needs to be specified for a "
                            "related measures t-test.")
        ct = Celltable(y, x, match, sub, cat=(c1, c0), ds=ds, coercion=asvar)
        c1, c0 = ct.cat
        if not ct.all_within:
            raise ValueError("conditions %r and %r do not have the same values "
                             "on %s" % (c1, c0, dataobj_repr(ct.match)))

        n = len(ct.Y) // 2
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.Y)
        self._x = dataobj_repr(ct.X)
        self.diff = ct.Y[:n] - ct.Y[n:]
        self.df = n - 1
        self.t = stats.t_1samp(self.diff.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
        self._c1 = c1
        self._c0 = c0