One-dominant composition with a target normalised Shannon entropy
Source:R/statistical_metrics.R
composition_from_entropy.RdReturns a length-\(J\) simplex vector of the form
\((1-(J-1)q,\,q,\ldots,q)\) whose normalised Shannon entropy
compute_shannon_entropy() equals h_star. The uniform composition
(h_star = 1) and a Dirac mass (h_star = 0) are returned exactly.
Examples
p <- composition_from_entropy(0.5, n_celltypes = 3L)
compute_shannon_entropy(p)
#> [1] 0.5