Python Forum
Help with correlation coefficient
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with correlation coefficient
#1
Trying to calculate the correlation coefficient between the two lists, so far no luck. Any suggestions or help would be greatly appreciated?

from table_utils import *
from stats_utils import *

cars = [29.9, 30.2, 30.3, 30.1, 30.3, 30.4, 30.5, 30.9, 31.1, 31.5, 31.7]
papers = [337, 322, 311, 299, 264, 242, 213, 191, 190, 174, 164]

car_list = []
papers_list = []

for car_row in cars:
    area = car_row[0]
    for papers_row in papers:
        if area == papers_row[1]: 
             car_list.append(float(car_row[1]))
             papers.append(float(papers_row[2])) 

corr = round(corr_coef(car_list, papers_list), 2)
print('Correlation coefficient =', corr)
Reply


Messages In This Thread
Help with correlation coefficient - by mattjb84 - Jun-29-2018, 07:38 PM
RE: Help with correlation coefficient - by j.crater - Jun-29-2018, 07:44 PM
RE: Help with correlation coefficient - by mattjb84 - Jun-29-2018, 08:15 PM
RE: Help with correlation coefficient - by Larz60+ - Jun-29-2018, 09:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Correlation Coefficents with different Time Ranges giaco__mar 0 870 Sep-28-2022, 02:03 PM
Last Post: giaco__mar
  How to get coefficient of determination R2 after scipy.curve_fit? AlekseyPython 0 1,901 Feb-12-2021, 09:03 AM
Last Post: AlekseyPython
  how to calculate overlaping coefficient between two probablity functions Staph 3 3,786 Aug-11-2019, 08:10 AM
Last Post: Staph
  Cross-correlation between 2 planes in a 3D array Mark3232 2 4,650 May-16-2019, 09:46 AM
Last Post: Mark3232
  do you know a code that will print all correlation values using numpty and panda? crispybluewaffle88 1 2,473 Mar-06-2019, 12:45 PM
Last Post: scidam
  Pandas dataframe: sum of exponentially weighted correlation matrices per row vvvcvvcv 1 3,294 May-29-2018, 01:09 AM
Last Post: scidam
  Mistake by correlation (x, y) Jack_Sparrow 2 2,755 May-10-2018, 02:23 PM
Last Post: volcano63
  Newbie question how to find the coefficient for each variable zydjohn 10 12,265 Dec-14-2017, 05:01 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020