Sort by

recency

|

116 Discussions

|

  • + 0 comments

    def calculate_sum(lst): total = 0 for element in lst: total += element return total

    def calculate_sum_of_squares(lst): total = 0 for element in lst: total += element**2 return total

    def calculate_sum_of_products(lst1, lst2): total = 0 for x, y in zip(lst1, lst2): total += x * y return total

    physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]

    n = len(physics_scores)

    sum_x = calculate_sum(physics_scores) sum_y = calculate_sum(history_scores) sum_xy = calculate_sum_of_products(physics_scores, history_scores) sum_x_squared = calculate_sum_of_squares(physics_scores) sum_y_squared = calculate_sum_of_squares(history_scores)

    numerator = n * sum_xy - sum_x * sum_y denominator = ((n * sum_x_squared - sum_x**2) * (n * sum_y_squared - sum_y**2))**0.5 correlation_coefficient = numerator / denominator

    print(f"{correlation_coefficient:.3f}")

  • + 0 comments

    from scipy.stats import pearsonr https://temuapps.click/ Given data physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]

    Calculate Pearson's correlation coefficient r, _ = pearsonr(physics_scores, history_scores)

    Print the result formatted to three decimal places print(f"{r:.3f}")

  • + 0 comments

    from scipy.stats import pearsonr

    Given data physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15] https://bestspickleball.com/

    Calculate Pearson's correlation coefficient r, _ = pearsonr(physics_scores, history_scores)

    Print the result formatted to three decimal places print(f"{r:.3f}")

  • + 0 comments

    from scipy.stats import pearsonr

    Given data

    physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]

    Calculate Pearson's correlation coefficient

    r, _ = pearsonr(physics_scores, history_scores)

    Print the result formatted to three decimal places

    print(f"{r:.3f}")

  • + 0 comments

    import numpy as np physics = np.array([15, 12, 8, 8, 7, 7, 7, 6, 5, 3]) history = np.array([10, 25, 17, 11, 13, 17, 20, 13, 9, 15])

    n= len(physics) # num of pairs of score

    calculate means

    mean_physics = np.mean(physics) mean_history = np.mean(history)

    calculate deviations

    dev_physics = physics - mean_physics dev_history = history- mean_history

    calculate the sum of product of deviations

    sum_prod_dev = np.sum(dev_physics * dev_history)

    calculate the sum of squared deviations

    sq_dev_physics = np.sum(dev_physics**2) sq_dev_history = np.sum(dev_history**2)

    calculate correlation coefficient

    r = sum_prod_dev/ np.sqrt(sq_dev_physics * sq_dev_history)

    print(f"Pearson's correlation coefficient: {r:.3f}")