def z_score(data):
    u = population_mean(data)
    new_data = [float(x) for x in data]
    x = new_data[1]
    pop_sd = pop_stand_dev(new_data)
    y = subtraction(x, u)
    z = division(pop_sd, y)
    return z
def pop_correlation_coefficient(data):
    x_data = CsvReader('Tests/Data/female_height.csv').data
    y_data = CsvReader('Tests/Data/male_height.csv').data
    x = pop_stand_dev(x_data)
    y = pop_stand_dev(y_data)
    divisor = multiplication(x, y)
    z = len(data)

    # Covariance calculation:
    a = subtraction(data, sampleMean)
    b = subtraction(data, population_mean)
    c = multiplication(a, b)
    covariance = division(z, (sum(c)))

    # Population Correlation Coefficient calculation:
    d = division(divisor, covariance)
    return d
Example #3
0
def pop_correlation_coefficient(data_x, data_y):
    x = pop_stand_dev(data_x)
    y = pop_stand_dev(data_y)
    divisor = multiplication(x, y)

    # Covariance calculation:
    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)

    # Population Correlation Coefficient calculation:
    d = division(divisor, covariance)
    return d
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
Example #5
0
def pop_correlation_coefficient(data):
    # x_data = CsvReader('Tests/Data/female_height.csv').data
    # y_data = CsvReader('Tests/Data/male_height.csv').data
    x_data = [num for elem in data for num in elem]
    y_data = [num for elem in data for num in elem]
    new_x_data = [float(x) for x in x_data]
    new_y_data = [float(x) for x in y_data]
    x = pop_stand_dev(new_x_data)
    y = pop_stand_dev(new_y_data)
    divisor = multiplication(x, y)
    z = len(new_x_data)

    # Covariance calculation:
    a = subtraction(new_x_data, population_mean(new_x_data))
    b = subtraction(new_y_data, population_mean(new_y_data))
    c = multiplication(a, b)
    covariance = division(z, (sum(c)))

    # Population Correlation Coefficient calculation:
    d = division(divisor, covariance)
    return d
Example #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
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
 def population_st_dev(self, data):
     self.result = pop_stand_dev(data)
     return self.result