Comparison.score.tsallis_entropy
Comparison.score.tsallis_entropy ¶
tsallis_entropy(
alpha: float = 1,
base: float = 2,
reference_score: float | Literal["mean"] | Expr = 0,
) -> Comparison
Calculates the difference in Tsallis entropy between the reference and comparison corpora.
Example
Tsallis entropy is a generalized measure of textual diversity, parameterized by an order \(\alpha\). This method takes the difference between the entropies of the reference corpus \(R\) and the comparison corpus \(C\):
where \(p_\tau^{(R)}\) and \(p_\tau^{(C)}\) are the normalized frequencies of a token \(\tau\) in \(R\) and \(C\) respectively.
Reference
For more details, see the following paper:
Gallagher, R. J., Frank, M. R., Mitchell, L., Schwartz, A. J., Reagan, A. J., Danforth, C. M., & Dodds, P. S. (2021). Generalized word shift graphs: a method for visualizing and explaining pairwise comparisons between texts. EPJ Data Science, 10(1), 4.
See Also
| Score | Description |
|---|---|
Comparison.score.shannon_entropy |
Scores corpora in the special case when \(\alpha=1\) |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
Order of the Tsallis entropy. \(\alpha = 1\) recovers Shannon entropy. Larger values place more weight on common tokens, and smaller values place more weight on rare tokens |
1
|
|
float
|
Base of the logarithms used to calculate the entropy when \(\alpha = 1\). Ignored otherwise |
2
|
|
float | Literal['mean'] | Expr
|
Baseline against which per-token contributions are interpreted. Defaults to 0.
If |
0
|
Returns:
| Type | Description |
|---|---|
Comparison
|
A new |