-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_correlation_coefficient.py
executable file
·27 lines (26 loc) · 1.57 KB
/
sample_correlation_coefficient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from nominal.pearsons_product_moment_correlation_coefficient import PearsonsProductMomentCorrelationCoefficient
from nominal.spearmans_rank_correlation_coefficient import SpearmansRankCorrelationCoefficient
if __name__ == '__main__':
args = sys.argv
if len(args) is not 2:
print "python sample_correlation_coefficient.py <sample_type>"
print "please choose sample type: "
print "1: pearson's product-moment correlation coefficient"
print "2: spearman's rank correlation coefficient"
else:
if args[1] == "1":
data = [[3,1], [2,4], [0,1], [2,3], [3,6], [5,5], [4,3], [6,5], [3,5], [1,2]]
pearsons_product_moment_correlation_coefficient = PearsonsProductMomentCorrelationCoefficient()
pearsons_product_moment_correlation_coefficient.test(data)
elif args[1] == "2":
data = [[4.3,3.9], [2.1,0.8], [1.4,0.9], [0.9,1.5], [0.5,0.5]]
spearmans_rank_correlation_coefficient = SpearmansRankCorrelationCoefficient()
spearmans_rank_correlation_coefficient.test(data)
else:
print "python sample_correlation_coefficient.py <sample_type>"
print "please choose sample type: "
print "1: pearson's product-moment correlation coefficient"
print "2: spearman's rank correlation coefficient"