emic.analysis¶
Complexity measures and machine analysis.
analysis
¶
Analysis module for epsilon-machine measures.
AnalysisSummary
dataclass
¶
AnalysisSummary(
statistical_complexity: float,
entropy_rate: float,
excess_entropy: float,
crypticity: float,
num_states: int,
num_transitions: int,
alphabet_size: int,
topological_complexity: float,
)
Complete analysis of an epsilon-machine.
Contains all computed measures for easy access and display.
to_dict
¶
Convert to dictionary for serialization.
Source code in src/emic/analysis/summary.py
__str__
¶
Return human-readable summary.
Source code in src/emic/analysis/summary.py
analyze
¶
analyze(machine: EpsilonMachine[A]) -> AnalysisSummary
Compute all standard measures for an epsilon-machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine to analyze |
required |
Returns:
| Type | Description |
|---|---|
AnalysisSummary
|
AnalysisSummary with all computed measures |
Examples:
>>> from emic.sources.synthetic.golden_mean import GoldenMeanSource
>>> machine = GoldenMeanSource(p=0.5).true_machine
>>> summary = analyze(machine)
>>> summary.num_states
2
Source code in src/emic/analysis/summary.py
statistical_complexity
¶
statistical_complexity(
machine: EpsilonMachine[A],
) -> float
Compute the statistical complexity Cμ.
Cμ = H(S) = -Σᵢ πᵢ log₂(πᵢ)
where πᵢ is the stationary probability of state i.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
float
|
Statistical complexity in bits |
Examples:
>>> from emic.sources.synthetic.golden_mean import GoldenMeanSource
>>> machine = GoldenMeanSource(p=0.5).true_machine
>>> 0.9 < statistical_complexity(machine) < 0.95
True
Source code in src/emic/analysis/measures.py
entropy_rate
¶
entropy_rate(machine: EpsilonMachine[A]) -> float
Compute the entropy rate hμ.
hμ = H(X | S) = Σᵢ πᵢ H(X | S = sᵢ)
where H(X | S = sᵢ) is the entropy of the emission distribution from state sᵢ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
float
|
Entropy rate in bits per symbol |
Examples:
>>> from emic.sources.synthetic.biased_coin import BiasedCoinSource
>>> machine = BiasedCoinSource(p=0.5).true_machine
>>> abs(entropy_rate(machine) - 1.0) < 0.01
True
Source code in src/emic/analysis/measures.py
excess_entropy
¶
excess_entropy(machine: EpsilonMachine[A]) -> float
Compute the excess entropy E = I(Past; Future).
Uses block entropy convergence:
E = lim_{L→∞} [ H(X₁, ..., X_L) - L · hμ ]
For a unifilar machine, block entropies H(X₁...X_L) are computed exactly by propagating the state distribution through the transition structure. The difference H(X₁...X_L) - L·hμ converges to E as L grows.
Note
E ≤ Cμ always. The gap χ = Cμ - E is the crypticity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
float
|
Excess entropy in bits |
Examples:
>>> from emic.sources.synthetic.biased_coin import BiasedCoinSource
>>> machine = BiasedCoinSource(p=0.5).true_machine
>>> abs(excess_entropy(machine)) < 1e-10
True
Source code in src/emic/analysis/measures.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
state_count
¶
state_count(machine: EpsilonMachine[A]) -> int
Number of causal states.
A simple but fundamental measure of structural complexity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of states |
Source code in src/emic/analysis/measures.py
transition_count
¶
transition_count(machine: EpsilonMachine[A]) -> int
Total number of transitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
int
|
Total number of transitions |
topological_complexity
¶
topological_complexity(
machine: EpsilonMachine[A],
) -> float
Topological complexity: log₂(number of states).
An upper bound on statistical complexity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
float
|
Topological complexity in bits |