コード例 #1
0
def samplestddev(a):
    try:
        variance = samplevariance(a)
        return round(squarerooting(variance), 5)
    except ZeroDivisionError:
        print("Error: Can't Divide by 0")
    except ValueError:
        print("Error: Check your data inputs")
コード例 #2
0
def stddev(num):
    try:
        variance_float = variance(num)
        return round(squarerooting(variance_float), 5)
    except ZeroDivisionError:
        print("Error: Can't Divide by 0")
    except ValueError:
        print("Error: Check your data inputs")
コード例 #3
0
def marginoferror(a, conf):

    n = len(a)
    z_critical = scipy.stats.norm.ppf(1 - (1 - conf) / 2)

    sample_stdev = samplestddev(a)
    se = sample_stdev/squarerooting(n)
    margin_of_error = z_critical * se

    return margin_of_error
コード例 #4
0
def confidence_interval_top(num):
    try:
        num_values = len(num)
        z = 1.96
        sd = stddev(num)
        avg = populationmean(num)
        return round(avg + (z * sd / squarerooting(num_values)), 5)
    except ZeroDivisionError:
        print("Error: Can't Divide by 0")
    except ValueError:
        print("Error: Check your data inputs")
コード例 #5
0
def findsamplesize(conf, width):

    z_critical = z_critical = scipy.stats.norm.ppf(1 - (1 - conf) / 2)
    z_critical_squared = squarerooting(z_critical)

    moe = width / 2
    p_hat  = .5

    q_hat = 1 - p_hat

    p_times_q = p_hat * q_hat

    z_div_moe = z_critical / moe
    z_div_moe_squared = squaring(z_div_moe)

    n = ceil(p_times_q * z_div_moe_squared)

    return n
コード例 #6
0
 def squareroot(self, a):
     self.result = squarerooting(a)
     return self.result
コード例 #7
0
def stddev(num):
    variance_num = variance(num)
    return round(squarerooting(variance_num), 4)
コード例 #8
0
ファイル: ConfidenceLow.py プロジェクト: hbr4/Mini-Project-2
def confidence_low(num):
    values = len(num)
    z = 1.96
    stdev1 = stddev(num)
    avg = populationmean(num)
    return (avg - (z * stdev1)) / (squarerooting(values))