"""
Implements t_test() function.
"""

from .decimalize import decimalize
from .mean import mean
from .standard_deviation import standard_deviation

def t_test(sample, x):
    """
    A one-sample `t-test`_ is a test that compares the mean of a sample to a known value, x.

    In this case, we're trying to determine whether the sample mean is equal to the value
    that we know, which is `x`. Usually the results are used to look up a `p-value`_, which,
    for a certain level of significance, will let you determine whether the null hypothesis
    (that there is no real difference between the mean of the sample and provided `x`) can
    be rejected or not.

    .. _`t-test`: http://en.wikipedia.org/wiki/Student's_t-test
    .. _`p-value`: http://en.wikipedia.org/wiki/P-value

    Equation:
        .. math::
            t = \\frac{\\bar{X} - \\mu}{sd_X}

    :math:`\\bar{X}` is the sample mean

    :math:`\\mu` is the provided value

    :math:`sd_X` is the sample standard deviation

    Args:
        sample: A list of numerical objects (the sample)
        x: The provided value to compare the mean of the sample to.

    Returns:
        A numerical object.

    Example:

        >>> t_test([1, 2, 3, 4, 5, 6], 3.385)
        0.150570344262835
    """

    sample = decimalize(sample)
    x = decimalize(x)
    mean_sample = decimalize(mean(sample))

    # Square root the length of the sample
    rootN = pow(len(sample), 0.5)
    rootN = decimalize(rootN)

    # get standard deviation of sample
    sample_sd = decimalize(standard_deviation(sample))

    # Compute the known value against the sample,
    # returning the t value
    t_statistic = ((mean_sample - x) / sample_sd) * rootN
    return(float(t_statistic))

@@ -36,43 +36,8 @@
 %22%22%0A%0A
-from .decimalize import decimalize%0A
 from
@@ -1232,62 +1232,8 @@
 %22%22%0A%0A
-    sample = decimalize(sample)%0A    x = decimalize(x)%0A
     
@@ -1246,27 +1246,16 @@
 ample = 
-decimalize(
 mean(sam
@@ -1250,33 +1250,32 @@
 e = mean(sample)
-)
 %0A%0A    # Square r
@@ -1340,38 +1340,8 @@
 0.5)
-%0A    rootN = decimalize(rootN)
 %0A%0A  
@@ -1397,19 +1397,8 @@
 d = 
-decimalize(
 stan
@@ -1419,17 +1419,16 @@
 (sample)
-)
 %0A%0A    # 

Remove unnecessary decimalize from t_test.