#NEWLINE# def summed_probabilities( self , choosers , alternatives ) : #NEWLINE# #INDENT# '\n        Calculate total probability associated with each alternative.\n\n        Parameters\n        ----------\n        choosers : pandas.DataFrame\n            Table describing the agents making choices, e.g. households.\n        alternatives : pandas.DataFrame\n            Table describing the things from which agents are choosing.\n\n        Returns\n        -------\n        probs : pandas.Series\n            Total probability associated with each alternative.\n\n        ' #NEWLINE# def normalize( s ) : #NEWLINE# #INDENT# return ( s / s . sum ( ) ) #NEWLINE# #UNINDENT# ( choosers , alternatives ) = self . apply_predict_filters ( choosers , alternatives ) #NEWLINE# probs = self . probabilities ( choosers , alternatives , filter_tables = False ) #NEWLINE# if ( self . probability_mode == 'single_chooser' ) : #NEWLINE# #INDENT# return ( normalize ( probs ) * len ( choosers ) ) . reset_index ( level = 0 , drop = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . probability_mode == 'full_product' ) : #NEWLINE# #INDENT# return probs . groupby ( level = 0 ) . apply ( normalize ) . groupby ( level = 1 ) . sum ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Unrecognized probability_mode option: {}' . format ( self . probability_mode ) )