Datasets:
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
information-theory
renyi-entropy
shannon-entropy
hidden-markov-models
bernoulli-convolutions
Download veloryn/examples.py from PureOne/VELORYN-Boundary-Kernel-Entropy: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/datasets/PureOne/VELORYN-Boundary-Kernel-Entropy/resolve/main/veloryn/examples.py
- Command line
-
hf download hf://datasets/PureOne/VELORYN-Boundary-Kernel-Entropy/veloryn/examples.py
-
curl -L -o examples.py https://huggingface.co/datasets/PureOne/VELORYN-Boundary-Kernel-Entropy/resolve/main/veloryn/examples.py
1.59 kB
| """Small exact models used by examples and the independent test suite.""" | |
| from fractions import Fraction as Q | |
| from .arithmetic import Field | |
| from .source import Source | |
| def fair(field="phi"): | |
| f=Field(field) | |
| return Source(f,1,[(0,0,0,1,Q(1,2)),(0,0,1,1,Q(1,2))],[1]) | |
| def markov(field="phi"): | |
| # Stationary pi=(4/5,1/5), zero transition 1 -> 1. | |
| f=Field(field) | |
| return Source(f,2,[(0,0,0,1,Q(3,4)),(0,1,1,1,Q(1,4)), | |
| (1,0,0,1,1)],[Q(4,5),Q(1,5)]) | |
| def periodic(field="phi"): | |
| f=Field(field) | |
| return Source(f,2,[(0,1,1,1,1),(1,0,0,1,1)],[Q(1,2),Q(1,2)]) | |
| def mixture(): | |
| return Source(Field("integer"),2,[(0,0,0,1,Q(1,2)),(0,0,1,1,Q(1,2)), | |
| (1,1,0,1,1)],[Q(1,2),Q(1,2)]) | |
| def variable(field="phi"): | |
| # Same two vertex transition probabilities as markov(), with branch clocks 1/2. | |
| return Source(Field(field),2,[(0,0,0,1,Q(3,4)),(0,1,1,2,Q(1,4)), | |
| (1,0,1,1,1)],[Q(4,5),Q(1,5)]) | |
| def hidden(): | |
| # Three hidden states, overlapping emissions, genuinely hidden rather than visible Markov digits. | |
| es=[(0,0,0,1,Q(1,2)),(0,1,1,2,Q(1,2)), | |
| (1,1,0,1,Q(1,2)),(1,2,1,1,Q(1,2)), | |
| (2,2,1,2,Q(1,2)),(2,0,0,1,Q(1,2))] | |
| return Source(Field("phi"),3,es,[Q(1,3)]*3) | |
| def correlated(field="phi"): | |
| # Stationary correlated source with both sides of arithmetic overlaps allowed. | |
| return Source(Field(field),2,[(0,0,0,1,Q(3,4)),(0,1,1,1,Q(1,4)), | |
| (1,0,0,1,Q(1,2)),(1,1,1,1,Q(1,2))], | |
| [Q(2,3),Q(1,3)]) | |