Shannon and Simpson Diversity

easy
Unit 3 · Statistics III0/3 to milestone

From category counts, implement:

  • shannon(counts) = −∑piln⁡pi-\sum p_i\ln p_i (natural log; zero counts ignored)
  • simpson(counts) = 1−∑pi21 - \sum p_i^2: the chance two random picks (with replacement) differ
  • effective_number(counts) = eHe^{H} (Hill number of order 1): "as diverse as this many equally common categories"
#statistics#information-theory2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Shannon and Simpson Diversity · TechGradify