entropy_weights
mcda.entropy_weights(normalized)
Shannon entropy weights for a [0, 1] normalized tool by metric matrix.
The principle: a metric on which every tool scores the same offers no discrimination and should not influence the ranking. A metric on which the tools spread out widely should weigh more. Shannon entropy is the canonical way to measure that spread.
Algorithm:
- Turn each column into a probability mass by dividing by its sum:
p[i, j] = normalized[i, j] / sum_k normalized[k, j]. - Compute the per-column entropy
E[j] = -(1 / ln n_tools) * sum_i p[i, j] * ln p[i, j], using the convention0 * ln 0 = 0. - Compute the per-column divergence
d[j] = 1 - E[j]. - Return weights
w[j] = d[j] / sum_k d[k].
The 1 / ln n_tools factor scales E into [0, 1], so d is also in [0, 1].
If every column has uniform variation, every divergence is zero and the weight vector would otherwise be 0 / 0. In that case the function falls back to equal weights.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
normalized |
np.ndarray | Shape (n_tools, n_metrics), values in [0, 1] (non-negative). |
required |
Returns
| Type | Description |
|---|---|
| np.ndarray | Shape (n_metrics,), non-negative weights summing to 1. |
Notes
Because the algorithm normalizes each column to a probability mass before computing entropy, the weights are invariant under positive rescaling of any single column: multiplying column j by a positive constant leaves w unchanged.