def read_signal_probs(file):
 f = open(file)
 lines = f.readlines()
 f.close()
 flow_probs = defaultdict(list)
 flow_logs = defaultdict(list)
 for line in lines:
  if line.startswith('#'):
   continue
  for (i, num) in enumerate(line.strip().split()[2::2]):
   flow_probs[i].append(float(num))
  for (i, num) in enumerate(line.strip().split()[1::2]):
   flow_logs[i].append(float(num))
 for p in flow_probs:
  s = sum(flow_probs[p])
  flow_probs[p] = [(i / s) for i in flow_probs[p]]
 return (flow_probs, flow_logs)

def read_signal_probs ( file ) : f = open ( file ) lines = f . readlines ( ) f . close ( ) flow_probs = defaultdict ( list ) flow_logs = defaultdict ( list ) for line in lines : if line . startswith ( '#' ) : continue for ( i , num ) in enumerate ( line . strip ( ) . split ( ) [ 2 : : 2 ] ) : flow_probs [ i ] . append ( float ( num ) ) for ( i , num ) in enumerate ( line . strip ( ) . split ( ) [ 1 : : 2 ] ) : flow_logs [ i ] . append ( float ( num ) ) for p in flow_probs : s = sum ( flow_probs [ p ] ) flow_probs [ p ] = [ ( i / s ) for i in flow_probs [ p ] ] return ( flow_probs , flow_logs )
read and check the signal probabilty file .