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.
E = I(Past; Future) = Cμ + Cμ' - I
For unifilar machines (which epsilon-machines are): E = Cμ (statistical complexity equals excess entropy)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
EpsilonMachine[A]
|
The epsilon-machine |
required |
Returns:
| Type | Description |
|---|---|
float
|
Excess entropy in bits |
Note
For general epsilon-machines, E = Cμ since they are unifilar.
Source code in src/emic/analysis/measures.py
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 |