示例#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)
示例#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)
示例#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)
示例#4
0
文件: idealg.py 项目: DCPROGS/HJCFIT
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)
示例#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))
示例#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))
示例#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)
示例#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)
示例#9
0
def step(context, n):
  from dcprogs.likelihood.random import qmatrix as random_qmatrix
  context.qmatrices = [random_qmatrix() for u in range(n)]