Example #1
0
def ap_categorical_sampler(obs, prior_weight, upper,
        size=(), rng=None, LF=DEFAULT_LF):
    weights = scope.linear_forgetting_weights(scope.len(obs), LF=LF)
    counts = scope.bincount(obs, minlength=upper, weights=weights)
    # -- add in some prior pseudocounts
    pseudocounts = counts + prior_weight
    return scope.categorical(pseudocounts / scope.sum(pseudocounts),
            upper=upper, size=size, rng=rng)
Example #2
0
def ap_categorical_sampler(obs,
                           prior_weight,
                           p,
                           upper=None,
                           size=(),
                           rng=None,
                           LF=DEFAULT_LF):
    weights = scope.linear_forgetting_weights(scope.len(obs), LF=LF)
    counts = scope.bincount(obs, minlength=upper, weights=weights)
    pseudocounts = scope.tpe_cat_pseudocounts(counts, upper, prior_weight, p,
                                              size)
    return scope.categorical(pseudocounts, upper=upper, size=size, rng=rng)
Example #3
0
def ap_categorical_sampler(obs, prior_weight, p, upper=None,
        size=(), rng=None, LF=DEFAULT_LF):
    weights = scope.linear_forgetting_weights(scope.len(obs), LF=LF)
    counts = scope.bincount(obs, minlength=upper, weights=weights)
    pseudocounts = scope.tpe_cat_pseudocounts(counts, upper, prior_weight, p, size)
    return scope.categorical(pseudocounts, upper=upper, size=size, rng=rng)