We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Artificial Intelligence
- Statistics and Machine Learning
- Correlation and Regression Lines - A Quick Recap #1
- Discussions
Correlation and Regression Lines - A Quick Recap #1
Correlation and Regression Lines - A Quick Recap #1
Sort by
recency
|
134 Discussions
|
Please Login in order to post a comment
This problem was a great refresher on calculating Pearson’s correlation coefficient manually. The value (0.145) shows a very weak positive correlation between Physics and History scores, meaning this site subjects don’t strongly influence each other.
“Interesting problem! Karl Pearson’s correlation really shows how data can uncover hidden relationships. I recently realized how similar concepts apply even outside of academics. For example, in home improvement projects like bathroom remodeling, we often analyze the correlation between budget, material quality, and customer satisfaction. By looking at patterns, we can predict which design choices will give the best long-term results.it’s fascinating how statistics tie into real-world projects too!
The tricky part with this one is keeping the calculation clean because the data has repeats. Once you plug it into the Pearson formula, the correlation actually comes out slightly negative, around -0.144. It shows that higher Physics scores don’t really align with higher History scores in this set.
Enter your code here. Read input from STDIN. Print output to STDOUT
I have submitted this code still getting compilation error physics_marks = [15,12,8,8,7,7,7,6,5,3] history_score = [10,25,17,11,13,17,20,13,9,15]
calculate correlation coefficient
x_avg = sum(physics_marks)/10 y_avg = sum(history_score)/10 corr_coeff_num = sum([(physics_marks[i] - x_avg)*(history_score[i]-y_avg) for i in range(10)]) corr_coeff_deno = (sum([(physics_marks[i]**2)for i in range(10)])*sum([(history_score[i]**2)for i in range(10)]))**0.5 correlation_coefficient = corr_coeff_num/corr_coeff_deno print(f"{correlation_coefficient:.3f}")
physics_marks = [15,12,8,8,7,7,7,6,5,3] history_score = [10,25,17,11,13,17,20,13,9,15]
calculate correlation coefficient
correlation_coefficient = np.corrcoef(physics_marks,history_score)[0,1]
x_avg = sum(physics_marks)/10 y_avg = sum(history_score)/10 corr_coeff_num = sum([(physics_marks[i] - x_avg)*(history_score[i]-y_avg) for i in range(10)]) corr_coeff_deno = (sum([(physics_marks[i]**2)for i in range(10)])*sum([(history_score[i]**2)for i in range(10)]))**0.5 correlation_coefficient = corr_coeff_num/corr_coeff_deno print(f"{correlation_coefficient:.3f}")