Skip to content

feat: add Markov chain entropy rate - #262

Draft
spedygiorgio wants to merge 4 commits into
masterfrom
agent/quick-win-entropy-rate
Draft

feat: add Markov chain entropy rate#262
spedygiorgio wants to merge 4 commits into
masterfrom
agent/quick-win-entropy-rate

Conversation

@spedygiorgio

Copy link
Copy Markdown
Owner

Summary

  • add entropyRate() as an S4 method for markovchain objects
  • compute the stationary entropy rate with robust handling of zero transition probabilities
  • support arbitrary valid logarithm bases, defaulting to bits (base = 2)
  • add roxygen2 documentation, examples, and regression tests

Mathematical definition

For stationary distribution pi and transition matrix P, the implementation evaluates H = -sum_i pi_i sum_j p_ij log(p_ij) with 0 log(0) = 0.

Implementation notes

No Rcpp is used: this is a compact vectorized calculation and does not benefit materially from a C++ wrapper.

Validation

  • analytical two-state chain
  • alternative logarithm base
  • structural zero transition
  • one-state chain
  • invalid logarithm bases

Closes #256.

@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.09%. Comparing base (fdea049) to head (98b7fe0).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
R/entropyRate.R 86.66% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #262      +/-   ##
==========================================
+ Coverage   57.71%   58.09%   +0.38%     
==========================================
  Files          26       28       +2     
  Lines        3876     4076     +200     
==========================================
+ Hits         2237     2368     +131     
- Misses       1639     1708      +69     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: add entropy rate of a Markov chain

2 participants