파이썬, 318 바이트 + 35 개 미스 분류
from scipy.stats import*
from numpy import*
def f(l):
r={'U':kstest(l,'uniform')[1],'T':kstest(l,'triang',args=(.5,))[1],'B':kstest(l,'beta',args=(.5,.5))[1],'E':kstest(l,'expon',args=(0,.5,))[1],'G':kstest(l,'gamma',args=(3,0,1/6.0))[1]}
if sum([x>1 for x in l]): r['U'],r['T'],r['B']=0,0,0
return max(r,key=r.get)
아이디어 : 분포는 Kolmogorov-Smirnov 검정의 p- 값을 기반으로 추측됩니다.
테스트
from scipy.stats import*
from numpy import*
import os
from io import StringIO
dir=os.path.dirname(os.path.abspath(__file__))+"/random-data-master/"
def f(l):
r={'U':kstest(l,'uniform')[1],'T':kstest(l,'triang',args=(.5,))[1],'B':kstest(l,'beta',args=(.5,.5))[1],'E':kstest(l,'expon',args=(0,.5,))[1],'G':kstest(l,'gamma',args=(3,0,1/6.0))[1]}
if sum([x>1 for x in l]): r['U'],r['T'],r['B']=0,0,0
return max(r,key=r.get)
U=[line.rstrip('\n').split(',') for line in open(dir+'U.txt')]
U=[[float(x) for x in r] for r in U]
T=[line.rstrip('\n').split(',') for line in open(dir+'T.txt')]
T=[[float(x) for x in r] for r in T]
B=[line.rstrip('\n').split(',') for line in open(dir+'B.txt')]
B=[[float(x) for x in r] for r in B]
E=[line.rstrip('\n').split(',') for line in open(dir+'E.txt')]
E=[[float(x) for x in r] for r in E]
G=[line.rstrip('\n').split(',') for line in open(dir+'G.txt')]
G=[[float(x) for x in r] for r in G]
i,_u,_t,_b,_e,_g=0,0,0,0,0,0
for u,t,b,e,g in zip(U,T,B,E,G):
_u+=1 if f(u)=='U' else 0
_t+=1 if f(t)=='T' else 0
_b+=1 if f(b)=='B' else 0
_e+=1 if f(e)=='E' else 0
_g+=1 if f(g)=='G' else 0
print f(u),f(t),f(b),f(e),f(g)
print _u,_t,_b,_e,_g,100*5-_u-_t-_b-_e-_g