def pop_correlation_coefficient(data_x, data_y):
    x = pop_stand_dev(data_x)
    y = pop_stand_dev(data_y)
    divisor = multiplication(x, y)

    d = population_mean(data_x)
    e = population_mean(data_y)
    a = [(element - d) for element in data_x]
    b = [(element - e) for element in data_y]
    size = len(a)
    product = [a[i] * b[i] for i in range(size)]
    total = sum(product)
    covariance = division(size, total)

    d = division(divisor, covariance)
    return d
Exemple #2
0
def z_score(numbers):
    row_value = 151
    std_dev = pop_stand_dev(numbers)
    mean = population_mean(numbers)
    result = subtraction(row_value, mean)
    z_score_ = division(result, std_dev)
    print(z_score_)
    return z_score_
def sample_std_dev(data):
    total = 0
    samples = random.randint(1, len(data))
    new_samples = get_sample(data, samples)
    new_mean = population_mean(new_samples)
    for number in new_samples:
        result = subtraction(number, new_mean)
        sq = square(result)
        total = addition(total, sq)
    n = len(new_samples)
    d = division(subtraction(1, n), total)
    sample_sd = sq_rt(d)
    return sample_sd
Exemple #4
0
def confidence_interval(data):
    z_value = 1.960
    mean = population_mean(data)
    sd = pop_stand_dev(data)

    x = len(data)
    y = division(sq_rt(x), sd)

    margin_of_error = multiplication(z_value, y)

    a = [subtraction(mean, margin_of_error)]
    b = [addition(mean, margin_of_error)]

    size = len(a)
    lower = a[0]
    upper = b[0]

    return lower, upper
def population_variance(data):
    pop = population_mean(data)
    length = len(data)
    return round(
        division(length, sum([(element - pop)**2 for element in data])), 3)
Exemple #6
0
 def population_mean(self, a):
     self.result = population_mean(a)
     return self.result
def pop_stand_dev(data):
    pop = population_mean(data)
    length = len(data)
    return round(sq_rt(sum([(element - pop)**2 for element in data]) / length),
                 3)