Skip to contents

Given a tidied dataframe of topic-doc or word-topic distributions and a target entropy, find the mean exponent needed to adjust the temperature of each distribution to approximately match the target entropy.

Usage

target_power(tidy_df, group_col, p_col, target_entropy)

Arguments

tidy_df

The tidied distribution dataframe

group_col

Grouping column, RHS of the conditional probability distribution, eg, topics for word-topic distributions

p_col

Column containing the probability for each category (eg, word) conditional on the group (eg, topic)

target_entropy

Target entropy

Value

Mean exponent to renormalize to the target entropy

Examples

# \donttest{
set.seed(42)
theta  = rdirichlet(50, 1, k = 3)
phi    = rdirichlet(3, 0.1, k = 20)
corpus = draw_corpus(rep(50L, 50), theta, phi)
model  = tmfast(corpus, n = 3)
beta   = tidy(model, matrix = 'beta', k = 3)
target_power(beta, topic, beta, target_entropy = 2)
#> [1] 0.5044985
# }