Datasets:
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
information-theory
renyi-entropy
shannon-entropy
hidden-markov-models
bernoulli-convolutions
File size: 1,883 Bytes
1c08905 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Generate exact certificate examples; timings are local observations, not benchmarks."""
from pathlib import Path
import json
import sys
import time
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
from veloryn.examples import fair,markov,variable,hidden,mixture,correlated
from veloryn.entropy import renyi_interval,shannon_interval
from veloryn.numerics import serializable
ROOT=Path(__file__).resolve().parents[1]
results=[]
cases=[('phi_fair_q2',fair(),128,2),('phi_markov_q2',markov(),128,2),
('salem_fair_q2',fair('salem'),64,2),('salem_markov_q2',markov('salem'),64,2),
('salem_fair_q3',fair('salem'),16,3),
('variable_phi_q2',variable(),24,2),('hidden_clock_q2',hidden(),16,2),
('mixture_cusp_q2',mixture(),16,2),
('salem_correlated_q2',correlated('salem'),64,2),
('phi_correlated_q2',correlated(),128,2)]
for name,source,n,q in cases:
started=time.perf_counter()
result=renyi_interval(source,n,q)
elapsed=time.perf_counter()-started
record={'name':name,'certificate':result,'elapsed_seconds_observed':elapsed}
results.append(record)
print(name,elapsed,[float(x) for x in result['interval_nats_per_branch']],
result['diagnostics']['max_layer_states'],flush=True)
(ROOT/'evidence'/f'{name}.json').write_text(json.dumps(serializable(record),indent=2)+'\n')
# The seed is deliberately labelled: no empirical coverage claim is made.
started=time.perf_counter()
source=variable()
shannon=shannon_interval(source,12,128,seed=20261001)
results.append({'name':'variable_shannon_demo','certificate':shannon,
'elapsed_seconds_observed':time.perf_counter()-started})
(ROOT/'evidence'/'example_certificates.json').write_text(json.dumps(serializable(results),indent=2)+'\n')
print('shannon demo',shannon['sampling_mode'],[float(x) for x in shannon['interval_nats_per_branch']])
|