예제 #1
0
def iguaisComOAnterior(jogo):
  '''
  jogo must implement get_dezenas()
  '''
  jogo_anterior = jogo.get_previous()
  if jogo_anterior == None:
    return 0
  return ffMetrics.getNOfCoincidences(jogo_anterior, jogo)
예제 #2
0
def calc_maxDeIguais(jogo):
  maxDeIguais = 0; distAo1o = 0; maxDeIguaisOcorrencia = 1; iguaisMediaComPassado = 0.0
  for nDoConc_to_compare in range(jogo.nDoConc - 1, 0, -1):
    jogo_to_compare = jogo.get_jogo_by_nDoConc(nDoConc_to_compare)
    nDeCoincsComAnteriores = ffMetrics.getNOfCoincidences(jogo, jogo_to_compare)
    iguaisMediaComPassado += nDeCoincsComAnteriores 
    if nDeCoincsComAnteriores > maxDeIguais:
      maxDeIguais = nDeCoincsComAnteriores
      distAo1o = jogo.nDoConc - nDoConc_to_compare
      maxDeIguaisOcorrencia = 1      
    elif nDeCoincsComAnteriores == maxDeIguais:
      maxDeIguaisOcorrencia += 1
  if jogo.nDoConc > 1:            
    iguaisMediaComPassado = iguaisMediaComPassado / (jogo.nDoConc - 1.0)
  return maxDeIguais, distAo1o, maxDeIguaisOcorrencia, iguaisMediaComPassado  
예제 #3
0
def maxDeIguais(jogo):
  maxDeIguais = 0
  distAo1o = -1
  for nDoConc_to_compare in range(jogo.nDoConc - 1, 0, -1):
    jogo_to_compare = jogo.get_jogo_by_nDoConc(nDoConc_to_compare)
    nDeCoincsComAnteriores = ffMetrics.getNOfCoincidences(jogo, jogo_to_compare)
    if nDeCoincsComAnteriores > maxDeIguais:
      maxDeIguais = nDeCoincsComAnteriores
      distAo1o = jogo.nDoConc - nDoConc_to_compare
      maxDeIguaisOcorrencia = 1      
    elif nDeCoincsComAnteriores == maxDeIguais:
      maxDeIguaisOcorrencia += 1      
  return maxDeIguais, distAo1o, maxDeIguaisOcorrencia  

    
  #  self.iguaisMediaComPassado = totalForMedia / (i + 0.0)

  #print nDoConc, 'self.iguaisComOAnterior', self.iguaisComOAnterior

  '''
  standard2LN = self.jogosObj.standard2LetterName
  # Note: only LF has minDeIguais and related fields
  if i > 0 and standard2LN == 'LF':
    UP_LIMIT_FOR_minDeIguais = 255
    self.minDeIguais = UP_LIMIT_FOR_minDeIguais
    for j in range(i):
      nOfBackConc = i-1-j + 1
      iguais = fCoincs.getNOfCoincidences(jogo, jogos[i-1-j])
      if iguais < self.minDeIguais:
        self.minDeIguais = iguais
        self.minDeIguaisDistAo1o = nDoConc - nOfBackConc
        self.minDeIguaisOcorrencia = 1
      elif iguais == self.minDeIguais and self.minDeIguaisOcorrencia > 0:
        self.minDeIguaisOcorrencia += 1
    #print 'self.minDeIguais', self.minDeIguais
  '''

  self.rem2pattern = ''
  self.parParImparImpar = ''
  self.rem3pattern = ''
  self.rem5pattern = ''
  self.rem6pattern = ''
  self.colpattern = ''
  for dezena in jogo:
    d = dezena % 2
    self.rem2pattern += str(d)
    dzn   = dezena / 10
    rDzn  = dzn % 2
    rUnit = d
    strDigit = '3'
    if rDzn==0:
      if rUnit==0:
        strDigit = '0'
      else:
        strDigit = '1'
    else: # ie, rDzn==1:
      if rUnit==0:
        strDigit = '2'
    self.parParImparImpar += strDigit
    d = dezena % 3
    self.rem3pattern += str(d)
    d = dezena % 5
    self.rem5pattern += str(d)
    d = dezena % 6
    self.rem6pattern += str(d)
    d = colFnct(dezena)
    self.colpattern += str(d)

  partialJogos = CLClasses.PartialJogos(self.jogosObj.standard2LetterName)
  partialJogos.setAteConcurso(nDoConc)
    
  til4obj = tilc.Til(partialJogos, 4)
  self.til4pattern = til4obj.generateLgiForJogoVsTilFaixas(jogo)
  # get later-on til4ocorrencia

  til5obj = tilc.Til(partialJogos, 5)
  self.til5pattern = til5obj.generateLgiForJogoVsTilFaixas(jogo)
  # get later-on til5ocorrencia

  til6obj = tilc.Til(partialJogos, 6)
  self.til6pattern = til6obj.generateLgiForJogoVsTilFaixas(jogo)
  # get later-on til6ocorrencia

  til10obj = tilc.Til(partialJogos, 10)
  self.til10pattern =  til10obj.generateLgiForJogoVsTilFaixas(jogo)
  # get later-on til10ocorrencia
  
      '''
    # consecutivos

    Eg.
    28 29 30 39 40 55
    This jogo has consec1=3 (ie, [28->29, 29->30, 39->40])
    This jogo has consec2=1 (ie, [28->29->30])
    This jogo has consec3=0 and all above (consec4 and consec5) are 0 too

    In the old implementation, there were:
    consecutivo1 ==> now, consec[0]
    consecutivo2 ==> now, consec[1]
    and so on

    The current implementation is also general, in the sense that it serves MS, LF and anyone, based on "self.jogosObj.nDeDezenasSorteadas"
    So consec[i] :: i from 0 to nDeDezenas - 1
    '''

      currentJogoObj = CLClasses.Jogo(jogo, self.jogosObj.standard2LetterName)
      jogoMenorAMaior = currentJogoObj.jogo
      self.consecEnc = funcs.calcConsec(jogoMenorAMaior)

      partialJogosList = partialJogos.getJogos()
      for n in somaNList: # defined here in Stat.py [1, 3, 7, 15]  (may change there)
        if nDoConc < n:
          exec('self.soma%d = None' %(n))
        else:
          soma = calcSomaN(jogo, partialJogosList, n) # calcSomaN defined here in Stat.py
          exec('self.soma%d = soma' %(n))
        somaN = eval('self.soma%d' %(n))
        if somaN == None:
          somaN = -1
        outLine = '%d soma%d=%d' %(nDoConc, n, somaN)
        self.logFile.write(outLine + '\n')

      na = numpy.array(jogo)
      self.std = na.std()
      del na

      self.binDecReprSomaDe1s = 0
      binDecRepr = currentJogoObj.getBinDecRepr()
      while binDecRepr > 0:
        digit = binDecRepr & 1
        self.binDecReprSomaDe1s += digit
        binDecRepr = binDecRepr >> 1

      # lgiDist
      self.lgiDist = 0
      if i > 0:
        lgi = currentJogoObj.getLgi()
        jogoObjAnt = CLClasses.Jogo(jogos[i-1], self.jogosObj.standard2LetterName)
        lgiAnt = jogoObjAnt.getLgi()
        self.lgiDist = lgi - lgiAnt

      # the current implementation needs jogo sorted crescently
      takeSquareRoot = True
      self.pathway  = self.radii.calculatePathway(currentJogoObj.jogo, takeSquareRoot)
      # make it integer "taking 2 decimal places"
      self.pathway  = int(self.pathway  * 100)
      self.allpaths = self.radii.calculateIntercrossed(currentJogoObj.jogo, takeSquareRoot)
      self.allpaths = int(self.allpaths * 100)

      #gauss = None
      #euclideandist = None
      #correlation = None
      #metricaZ = None

      '''
      self.origDrawnOrderQuad = 0; self.origDrawCresceDesce = 0
      jogoInOrder = self.jogosObj.getJogoInOrder(nDoConc)
      if not jogoInOrder:
        continue
      for j in range(len(jogo)):
        dezena = jogo[j]
        origIndex = jogoInOrder.index(dezena)
        dist = origIndex - j
        if dist > 0:
          self.origDrawCresceDesce += 1
        if dist < 0:
          self.origDrawCresceDesce -= 1
        self.origDrawnOrderQuad += dist ** 2
      self.origDrawnPattern = produceOrigDrawnPattern(jogoInOrder)
      '''

        
      self.updateDB(nDoConc)