Repository navigation
FiniteStateChannel: use Mealy-machine channels with dit channel codes - #34
Merged
Merged
Conversation
MealyMachine.__dit_channel__ wraps a stochastic transducer as a FiniteStateChannel implementing dit.coding's channel protocol: forward-algorithm likelihoods, state-path sampling, BCJR symbol likelihoods, and a no-feedback capacity bracket. Factor the initial-state law out of channel_tensors. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes every stochastic
MealyMachine, and so every ε-transducer, usable as a channel fordit.codingchannel codes. It implements dit's duck-typed channel protocol from dit/dit#301, so dit needs no knowledge of sofic.MealyMachine.__dit_channel__()returns a newFiniteStateChannel. It is exported fromsofic.generatorsandsofic.FiniteStateChannelprovides:log_likelihood: the scaled forward algorithm. It is exact for any finite-state channel, unifilar or not.sample: draws a state path from the initial law.symbol_log_likelihoods: forward-backward (BCJR) under uniform i.i.d. inputs. dit's LDPC, polar, and soft-Viterbi decoders use these values.capacity(**kw): the(lower, upper)no-feedback bracket fromsofic.generators.capacity.capacity. The codes don't use feedback."0"becomes0);input_mapandoutput_mapoverride this.channel_tensorsintoinitial_law, which both use.docs/generators/channel_coding.rstpage,Bahl1974added todocs/references.bib, and a CHANGELOG entry.Depends on dit/dit#301. The new tests skip themselves when the installed dit has no
dit.coding.as_channel. Raise thedit>=2.3floor once a dit release includes that PR.Test plan
tests/test_channel_coding.py:trapdoorandising_channellikelihoods and BCJR symbol likelihoods match brute-force sums over state paths.binary_channel(p, p)matches dit's binary symmetric channel.capacity_gapreturns a bracket that contains the binary symmetric channel's gap.ruff check/ruff format --checkclean.Made with Cursor