Exemplo n.º 1
0
def SampleTopicRelWeights(state):
    """Computes P(zr|zt) for each zr, zt.
  The return value is a matrix such that weights[i,j] = P(zr=j|zt=i)
  """
    alpha = state.hypers['alpha']
    counts = cCollect.TabulateTopicRelationCounts(state) + alpha
    weights = cDists.SampleDirichletArray(counts)
    return weights
Exemplo n.º 2
0
def SampleTopicSubWeights(state):
    """Update the distribution over subjects for each table topic.

  Computes P(zs|zt) for each zs, zt.
  The return value is a matrix such that weights[i,j] = P(zs=j|zt=i)
  """
    alpha = state.hypers['alpha_sub']
    counts = cCollect.TabulateTopicSubjectCounts(state) + alpha
    weights = cDists.SampleDirichletArray(counts)
    return weights
Exemplo n.º 3
0
def SampleTypeSubWeights(state):
    obs_counts = cCollect.TabulateRangeSubjectCounts(state)
    alpha = state.hypers['alpha']
    weights = cDists.SampleDirichletArray(obs_counts + alpha)
    return weights
Exemplo n.º 4
0
def SampleRelTokenWeights(state):
    alpha = state.hypers['alpha_token']
    counts = cCollect.TabulateRelationTokenCounts(state) + alpha
    weights = cDists.SampleDirichletArray(counts)
    return weights