Example #1
0
def step(context, n):
  from dcprogs.likelihood import DeterminantEq
  from dcprogs.likelihood.random import qmatrix as random_qmatrix
  context.matrices = []
  context.equations = []
  while len(context.equations) < n:
    try:
      matrix = random_qmatrix()
      equation =  DeterminantEq(matrix, 1e-4)
    except: continue
    else:
      context.matrices.append(matrix)
      context.equations.append(equation)
Example #2
0
def step(context, n):
    from dcprogs.likelihood import DeterminantEq
    from dcprogs.likelihood.random import qmatrix as random_qmatrix
    context.matrices = []
    context.equations = []
    while len(context.equations) < n:
        try:
            matrix = random_qmatrix()
            equation = DeterminantEq(matrix, 1e-4)
        except:
            continue
        else:
            context.matrices.append(matrix)
            context.equations.append(equation)
Example #3
0
def step(context, n, tau):
  from dcprogs.likelihood.random import qmatrix as random_qmatrix
  from dcprogs.likelihood import ApproxSurvivor
  qmatrices, survivors, i = [], [], 10*n
  while len(survivors) != n:
    i -= 1
    if i == 0: raise AssertionError('Could not instanciate enough survivor functions.')
    qmatrix = random_qmatrix()
    try: survivor = ApproxSurvivor(qmatrix, tau)
    except: continue
    else: survivors.append(survivor)
  if not hasattr(context, 'qmatrices'): context.qmatrices = []
  if not hasattr(context, 'survivors'): context.survivors = []
  context.qmatrices.extend(qmatrices)
  context.survivors.extend(survivors)
Example #4
0
def step(context, n):
  from dcprogs.likelihood.random import qmatrix as random_qmatrix
  from dcprogs.likelihood import IdealG
  qmatrices, Gs, i = [], [], 10*n
  while len(Gs) != n:
    i -= 1
    if i == 0: raise AssertionError('Could not instanciate enough likelihoods.')
    qmatrix = random_qmatrix()
    try: G = IdealG(qmatrix)
    except: continue
    else:
      Gs.append(G)
      qmatrices.append(qmatrix)
  if not hasattr(context, 'qmatrices'): context.qmatrices = []
  if not hasattr(context, 'likelihoods'): context.likelihoods = []
  context.qmatrices.extend(qmatrices)
  context.likelihoods.extend(Gs)
Example #5
0
def QMat(string):
  """ Creates matrices from specific strings """
  from dcprogs.likelihood.random import qmatrix as random_qmatrix
  from dcprogs.likelihood import QMatrix

  string = string.lower().rstrip().lstrip()
  if 'transpose' in string:
    return QMat(string.replace('transpose', '')).transpose()

  if string == "classic" or string == "ch82": return QMatrix(Matrix(string), 2)
  if string == "cb": return QMatrix(Matrix(string), 1)
  if string == "cks": return QMatrix(Matrix(string), 1)
  if string == "complex eigenvalues": return QMatrix(Matrix(string), 4)
  if string == "singular matrix": return QMatrix(Matrix(string), 3)
  if string == "random": return random_qmatrix()
  if string == "too many roots": return QMatrix(Matrix(string), 3)
  else: raise Exception("Unknown QMatrix {0}".format(string))
Example #6
0
def QMat(string):
    """ Creates matrices from specific strings """
    from dcprogs.likelihood.random import qmatrix as random_qmatrix
    from dcprogs.likelihood import QMatrix

    string = string.lower().rstrip().lstrip()
    if 'transpose' in string:
        return QMat(string.replace('transpose', '')).transpose()

    if string == "classic" or string == "ch82":
        return QMatrix(Matrix(string), 2)
    if string == "cb": return QMatrix(Matrix(string), 1)
    if string == "cks": return QMatrix(Matrix(string), 1)
    if string == "complex eigenvalues": return QMatrix(Matrix(string), 4)
    if string == "singular matrix": return QMatrix(Matrix(string), 3)
    if string == "random": return random_qmatrix()
    if string == "too many roots": return QMatrix(Matrix(string), 3)
    else: raise Exception("Unknown QMatrix {0}".format(string))
Example #7
0
def step(context, n):
    from dcprogs.likelihood.random import qmatrix as random_qmatrix
    from dcprogs.likelihood import IdealG
    qmatrices, Gs, i = [], [], 10 * n
    while len(Gs) != n:
        i -= 1
        if i == 0:
            raise AssertionError('Could not instanciate enough likelihoods.')
        qmatrix = random_qmatrix()
        try:
            G = IdealG(qmatrix)
        except:
            continue
        else:
            Gs.append(G)
            qmatrices.append(qmatrix)
    if not hasattr(context, 'qmatrices'): context.qmatrices = []
    if not hasattr(context, 'likelihoods'): context.likelihoods = []
    context.qmatrices.extend(qmatrices)
    context.likelihoods.extend(Gs)
Example #8
0
def step(context, n, tau):
    from dcprogs.likelihood.random import qmatrix as random_qmatrix
    from dcprogs.likelihood import ApproxSurvivor
    qmatrices, survivors, i = [], [], 10 * n
    while len(survivors) != n:
        i -= 1
        if i == 0:
            raise AssertionError(
                'Could not instanciate enough survivor functions.')
        qmatrix = random_qmatrix()
        try:
            survivor = ApproxSurvivor(qmatrix, tau)
        except:
            continue
        else:
            survivors.append(survivor)
    if not hasattr(context, 'qmatrices'): context.qmatrices = []
    if not hasattr(context, 'survivors'): context.survivors = []
    context.qmatrices.extend(qmatrices)
    context.survivors.extend(survivors)
Example #9
0
def step(context, n):
  from dcprogs.likelihood.random import qmatrix as random_qmatrix
  context.qmatrices = [random_qmatrix() for u in range(n)]