#NEWLINE# def anovar2( data_group , data_y ) : #NEWLINE# #INDENT# n = len ( data_group ) #NEWLINE# assert ( n == len ( group_index ) ) #NEWLINE# group_index = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for x in data_group : #NEWLINE# #INDENT# if ( x not in group_index ) : #NEWLINE# #INDENT# group_index [ x ] = len ( group_index ) #NEWLINE# #UNINDENT# #UNINDENT# n_groups = len ( group_index ) #NEWLINE# if ( n_groups == 0 ) : #NEWLINE# #INDENT# return ( float ( 'NaN' ) , n_groups ) #NEWLINE# #UNINDENT# if ( n_groups == n ) : #NEWLINE# #INDENT# return ( float ( 'NaN' ) , n_groups ) #NEWLINE# #UNINDENT# if ( n_groups == 1 ) : #NEWLINE# #INDENT# return ( float ( 'NaN' ) , n_groups ) #NEWLINE# #UNINDENT# groups = ( [ None ] * n_groups ) #NEWLINE# for i in xrange ( n_groups ) : #NEWLINE# #INDENT# groups [ i ] = [ ] #NEWLINE# #UNINDENT# for ( x , y ) in zip ( data_group , data_y ) : #NEWLINE# #INDENT# groups [ group_index [ x ] ] . append ( y ) #NEWLINE# #UNINDENT# F = stats . f_oneway ( groups ) #NEWLINE# return ( F , n_groups )