C# 상관계수 (Correl 함수) 구현
URL: http://be2u.tistory.com/144
상관관계에 대한 공식 정리
c# 기반 소스 코드
private float Correlation(List<float> xList, List<float> yList) float multiplyXYSigma = 0; float xPowSigma = 0; for (int i = 0; i < xList.Count; i++) xPowSigma += (float)Math.Pow(xList[i],2); result = ((n * multiplyXYSigma) - (xSigma * ySigma)) / return result; |
float 리스트들에 대해서도 처리를 하기위해, List<float> 타입으로 파라미터를 받도록 설계하였다.
리턴값의 절대값이 1에 가까울수록 두개의 분포도는 직선을 이룬다.
상관관계에 대한 설명 참조 : http://mathworld.wolfram.com/CorrelationCoefficient.html