<s> from modules . model import Model <EOL> from modules . validations import is_required , is_string , is_dict <EOL> from modules . sequencer . guess_pmf import GuessPMF <EOL> from modules . sequencer . slip_pmf import SlipPMF <EOL> from modules . sequencer . params import init_guess , init_slip , precision , init_transit <EOL> class CardParameters ( Model ) : <EOL> tablename = '<STR_LIT>' <EOL> schema = dict ( Model . schema . copy ( ) , ** { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : ( is_required , is_string ) , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : ( is_required , is_dict , ) , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : ( is_required , is_dict , ) , <EOL> } , <EOL> } ) <EOL> def get_distribution ( self , kind ) : <EOL> """<STR_LIT>""" <EOL> key = '<STR_LIT>' . format ( kind = kind ) <EOL> if key in self : <EOL> distribution = self [ key ] <EOL> distribution = { float ( k ) : v for k , v in distribution . items ( ) } <EOL> else : <EOL> init = init_guess if kind == '<STR_LIT>' else init_slip <EOL> distribution = { <EOL> h : <NUM_LIT:1> - ( init - h ) ** <NUM_LIT:2> <EOL> for h in [ h / precision for h in range ( <NUM_LIT:1> , precision ) ] <EOL> } <EOL> if kind == '<STR_LIT>' : <EOL> return GuessPMF ( distribution ) <EOL> if kind == '<STR_LIT>' : <EOL> return SlipPMF ( distribution ) <EOL> def set_distribution ( self , kind , distribution ) : <EOL> """<STR_LIT>""" <EOL> key = '<STR_LIT>' . format ( kind = kind ) <EOL> self [ key ] = { str ( k ) : v for k , v in distribution . hypotheses . items ( ) } <EOL> return self <EOL> def get_guess ( self ) : <EOL> """<STR_LIT>""" <EOL> guess_distribution = self . get_distribution ( '<STR_LIT>' ) <EOL> return guess_distribution . get_value ( ) <EOL> def get_slip ( self ) : <EOL> """<STR_LIT>""" <EOL> slip_distribution = self . get_distribution ( '<STR_LIT>' ) <EOL> return slip_distribution . get_value ( ) <EOL> def get_transit ( self ) : <EOL> """<STR_LIT>""" <EOL> return init_transit <EOL> def get_num_learners ( self ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def get_values ( self ) : <EOL> """<STR_LIT>""" <EOL> return { <EOL> '<STR_LIT>' : self . get_guess ( ) , <EOL> '<STR_LIT>' : self . get_slip ( ) , <EOL> '<STR_LIT>' : self . get_transit ( ) , <EOL> '<STR_LIT>' : self . get_num_learners ( ) , <EOL> } </s>
