コード例 #1
0
def proportion(data):
    p = len(data)
    height = 0
    for values in data:
        if height > 64:
            addition(height)
    return division(values, p)
コード例 #2
0
def sample_st_dev(data):
    mean = sampleMean(data)
    sample_data = data[0:999]
    tot = 0.0
    for x in sample_data:
        tot = addition(tot, (x - mean)**2)
    return round((tot / (len(sample_data) - 1))**0.5, 2)
コード例 #3
0
def sampleMean(data, sample_size):
    total = 0
    sample = sampleData(data, sample_size)
    sample_values = len(sample)
    for value in sample:
        total = addition(total, value)
    return division(total, sample_values)
コード例 #4
0
def confidence_interval(data):
    # For a Confidence Interval of 95%
    z_value = 1.960
    mean = sampleMean(data)
    sd = pop_stand_dev(data)
    x = len(data)
    y = division(square_root(x), sd)
    margin_of_error = multiplication(z_value, y)
    a = subtraction(mean, margin_of_error)
    b = addition(mean, margin_of_error)
    return a, b
コード例 #5
0
def sample_st_dev(data, sample_size):
    dev = 0
    sample = sampleData(data, sample_size)
    sample_values = len(sample)
    x_bar = sampleMean()
    x = sample_values
    n = subtraction(sample_values, 1)
    for dev in sample:
        dev = subtraction(x, x_bar)
        square_x_bar = square(dev)
        add = addition(square_x_bar, square_x_bar)
        divide = division(add, n)
    return square_root(divide)
コード例 #6
0
def confidence_interval(data):
    data = [num for elem in data for num in elem]
    new_data = [float(x) for x in data]
    # For a Confidence Interval of 95%
    z_value = 1.960
    mean = sampleMean(new_data)
    sd = pop_stand_dev(new_data)
    x = len(new_data)
    y = division(square_root(x), sd)
    margin_of_error = multiplication(z_value, y)
    a = subtraction(mean, margin_of_error)
    b = addition(mean, margin_of_error)
    return a, b
コード例 #7
0
def confidence_interval(data):
    # For a Confidence Interval of 95%
    z_value = 1.960
    mean = population_mean(data)
    sd = pop_stand_dev(data)
    x = len(data)
    y = division(square_root(x), sd)
    margin_of_error = multiplication(z_value, y)
    a = [subtraction(mean, margin_of_error)]
    b = [addition(mean, margin_of_error)]
    size = len(a)
    # c = [(a[i], b[i]) for i in range(size)]
    lower = a[0]
    upper = b[0]
    # print(lower, upper)
    return lower, upper
コード例 #8
0
 def add(self, a, b):
     self.result = addition(float(a), float(b))
     return self.result
コード例 #9
0
def population_mean(data):
    n = len(data)
    total = 0
    for item in data:
        total = addition(total, item)
    return division(total, n)