def evaluate( self, *args, **params):
     listLegend= list()
     listPlot = list()
     for x, y, title in args:
         xlabel, ylabel = title.split(u" VS ")
         listPlot.append( pltobj( None, xlabel= xlabel, ylabel= ylabel, title= title ))
         plt= listPlot[-1]
         (x, y) = homogenize( x, y)
         line=  linregress(x,y)
         yfit= lambda x: x*line[0]+line[1]
         plot= plt.plot(x,y,'b.',x,[yfit(x1) for x1 in x],'r')
         legend= plt.legend(plot,( title,__(u'linear Regression')), prop = PROPLEGEND)
         legend.draggable(state=True)
         arrow_args = dict(arrowstyle="->")
         bbox_args = dict(boxstyle="round", fc="w")
         text2anotate = "y="+str( round( line[0],4)) + \
             "x"
         if round( line[1],4) > 0:
             text2anotate += "+" + str( round( line[1],4))
         elif round(line[1],4) < 0:
             text2anotate += str( round( line[1],4))
         text2anotate += "\n r = " + str( round( line[2],6))
         an1= plt.annotate( text2anotate, xy=(x[int( len( x)/2)],
                                             yfit( x[int( len( x)/2)])),  xycoords='data',
                                             ha="center", va="center",
                                             bbox=bbox_args,
                                             arrowprops=arrow_args)
         an1.draggable()
         plt.updateControls()
         plt.canvas.draw()
     return listPlot
Ejemplo n.º 2
0
 def test_linregress(self):
     "Testing linregress"
     
     data1 = [ self.L, self.A ]
     data2 = [ self.M, self.B ]
     results = (1.0150375939849625, 3.8421052631578938, 0.80208084775070976, 2.1040104471429959e-005, 4.3580363930338537)
 
     i = 0
     for d in data1: # so check the first two of results...
        self.assertEqual( stats.linregress( d, data2[i] )[i], results[i] )
        i += 1
Ejemplo n.º 3
0
 def test_linregress(self):
     "Testing linregress"
     
     data1 = [ self.L, self.A ]
     data2 = [ self.M, self.B ]
     results = (1.0150375939849625, 3.8421052631578938, 0.80208084775070976, 2.1040104471429959e-005, 4.3580363930338537)
 
     i = 0
     for d in data1: # so check the first two of results...
        self.assertEqual( stats.linregress( d, data2[i] )[i], results[i] )
        i += 1
Ejemplo n.º 4
0
print()
print()
print('pearsonr:')
print(stats.pearsonr(l, m))
print(stats.pearsonr(a, b))
print('spearmanr:')
print(stats.spearmanr(l, m))
print(stats.spearmanr(a, b))
print('pointbiserialr:')
print(stats.pointbiserialr(pb, l))
print(stats.pointbiserialr(apb, a))
print('kendalltau:')
print(stats.kendalltau(l, m))
print(stats.kendalltau(a, b))
print('linregress:')
print(stats.linregress(l, m))
print(stats.linregress(a, b))

print('\nINFERENTIAL')
print('ttest_1samp:')
print(stats.ttest_1samp(l, 12))
print(stats.ttest_1samp(a, 12))
print('ttest_ind:')
print(stats.ttest_ind(l, m))
print(stats.ttest_ind(a, b))
print('ttest_rel:')
print(stats.ttest_rel(l, m))
print(stats.ttest_rel(a, b))
print('chisquare:')
print(stats.chisquare(l))
print(stats.chisquare(a))
 def evaluate( self, *args, **params):
     return _stats.linregress(*args, **params)
Ejemplo n.º 6
0
print
print
print 'pearsonr:'
print stats.pearsonr(l,m)
print stats.pearsonr(a,b)
print 'spearmanr:'
print stats.spearmanr(l,m)
print stats.spearmanr(a,b)
print 'pointbiserialr:'
print stats.pointbiserialr(pb,l)
print stats.pointbiserialr(apb,a)
print 'kendalltau:'
print stats.kendalltau(l,m)
print stats.kendalltau(a,b)
print 'linregress:'
print stats.linregress(l,m)
print stats.linregress(a,b)

print '\nINFERENTIAL'
print 'ttest_1samp:'
print stats.ttest_1samp(l,12)
print stats.ttest_1samp(a,12)
print 'ttest_ind:'
print stats.ttest_ind(l,m)
print stats.ttest_ind(a,b)
print 'ttest_rel:'
print stats.ttest_rel(l,m)
print stats.ttest_rel(a,b)
print 'chisquare:'
print stats.chisquare(l)
print stats.chisquare(a)
Ejemplo n.º 7
0
print stats.aspearmanr(array(x), array(y))

print '\n\nPoint-Biserial r'

gender = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2]
score = [35, 38, 41, 40, 60, 65, 65, 68, 68, 64]
print '\nSHOULD BE +0.981257 (N=10) ... Basic Stats 1st ed, p.197'
print stats.pointbiserialr(gender, score)
print stats.apointbiserialr(array(gender), array(score))

print '\n\nLinear Regression'

x = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
y = [2, 4, 4, 6, 2, 4, 7, 8, 6, 8, 7]
print '\nSHOULD BE 1.44, 1.47, 0.736, ???, 1.42 (N=11)... Basic Stats 1st ed, p.211-2'
print stats.linregress(x, y)
print stats.alinregress(array(x), array(y))

print '\n\nChi-Square'

fo = [10, 40]
print '\nSHOULD BE 18.0, <<<0.01 (df=1) ... Basic Stats 1st ed. p.457'
print stats.chisquare(fo)
print stats.achisquare(array(fo))
print '\nSHOULD BE 5.556, 0.01<p<0.05 (df=1) ... Basic Stats 1st ed. p.460'
print stats.chisquare(fo, [5, 45])
print stats.achisquare(array(fo), array([5, 45], 'f'))

print '\n\nMann Whitney U'

red = [540, 480, 600, 590, 605]
Ejemplo n.º 8
0
print '\n\nPoint-Biserial r'

gender = [1,1,1,1,2,2,2,2,2,2]
score  = [35, 38, 41, 40, 60, 65, 65, 68, 68, 64]
print '\nSHOULD BE +0.981257 (N=10) ... Basic Stats 1st ed, p.197'
print stats.pointbiserialr(gender,score)
print stats.apointbiserialr(array(gender),array(score))


print '\n\nLinear Regression'

x = [1,1,2,2,2,3,3,3,4,4,4]
y = [2,4,4,6,2,4,7,8,6,8,7]
print '\nSHOULD BE 1.44, 1.47, 0.736, ???, 1.42 (N=11)... Basic Stats 1st ed, p.211-2'
print stats.linregress(x,y)
print stats.alinregress(array(x),array(y))

print '\n\nChi-Square'

fo = [10,40]
print '\nSHOULD BE 18.0, <<<0.01 (df=1) ... Basic Stats 1st ed. p.457'
print stats.chisquare(fo)
print stats.achisquare(array(fo))
print '\nSHOULD BE 5.556, 0.01<p<0.05 (df=1) ... Basic Stats 1st ed. p.460'
print stats.chisquare(fo,[5,45])
print stats.achisquare(array(fo),array([5,45],'f'))


print '\n\nMann Whitney U'
Ejemplo n.º 9
0
print
print
print 'pearsonr:'
print stats.pearsonr(l, m)
print stats.pearsonr(a, b)
print 'spearmanr:'
print stats.spearmanr(l, m)
print stats.spearmanr(a, b)
print 'pointbiserialr:'
print stats.pointbiserialr(pb, l)
print stats.pointbiserialr(apb, a)
print 'kendalltau:'
print stats.kendalltau(l, m)
print stats.kendalltau(a, b)
print 'linregress:'
print stats.linregress(l, m)
print stats.linregress(a, b)

print '\nINFERENTIAL'
print 'ttest_1samp:'
print stats.ttest_1samp(l, 12)
print stats.ttest_1samp(a, 12)
print 'ttest_ind:'
print stats.ttest_ind(l, m)
print stats.ttest_ind(a, b)
print 'ttest_rel:'
print stats.ttest_rel(l, m)
print stats.ttest_rel(a, b)
print 'chisquare:'
print stats.chisquare(l)
print stats.chisquare(a)
Ejemplo n.º 10
0
print('\n\nPoint-Biserial r')

gender = [1,1,1,1,2,2,2,2,2,2]
score  = [35, 38, 41, 40, 60, 65, 65, 68, 68, 64]
print('\nSHOULD BE +0.981257 (N=10) ... Basic Stats 1st ed, p.197')
print(stats.pointbiserialr(gender,score))
print(stats.apointbiserialr(array(gender),array(score)))


print('\n\nLinear Regression')

x = [1,1,2,2,2,3,3,3,4,4,4]
y = [2,4,4,6,2,4,7,8,6,8,7]
print('\nSHOULD BE 1.44, 1.47, 0.736, ???, 1.42 (N=11)... Basic Stats 1st ed, p.211-2')
print(stats.linregress(x,y))
print(stats.alinregress(array(x),array(y)))

print('\n\nChi-Square')

fo = [10,40]
print('\nSHOULD BE 18.0, <<<0.01 (df=1) ... Basic Stats 1st ed. p.457')
print(stats.chisquare(fo))
print(stats.achisquare(array(fo)))
print('\nSHOULD BE 5.556, 0.01<p<0.05 (df=1) ... Basic Stats 1st ed. p.460')
print(stats.chisquare(fo,[5,45]))
print(stats.achisquare(array(fo),array([5,45],'f')))


print('\n\nMann Whitney U')