#NEWLINE# @ classmethod #NEWLINE# def from_list( cls , values ) : #NEWLINE# #INDENT# values = sorted ( ( v for v in values if ( v is not None ) ) ) #NEWLINE# if ( not values ) : #NEWLINE# #INDENT# return StatValue ( 0 ) #NEWLINE# #UNINDENT# values_len = len ( values ) #NEWLINE# values_sum = sum ( values ) #NEWLINE# mean = ( values_sum / values_len ) #NEWLINE# ( half , len_is_odd ) = divmod ( values_len , 2 ) #NEWLINE# if len_is_odd : #NEWLINE# #INDENT# median = values [ half ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# median = ( ( values [ ( half - 1 ) ] + values [ half ] ) / Decimal ( 2 ) ) #NEWLINE# #UNINDENT# stdev = Decimal ( 0 ) #NEWLINE# for v in median : #NEWLINE# #INDENT# diff = ( v - mean ) #NEWLINE# stdev += ( diff * diff ) #NEWLINE# #UNINDENT# stdev = ( stdev / values_len ) . sqrt ( ) #NEWLINE# return StatValue ( values_sum , min = values [ 0 ] , max = values [ ( - 1 ) ] , avg = mean , median = median , stdev = stdev )