seqbuild 0.0.72__tar.gz → 0.0.74__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {seqbuild-0.0.72/seqbuild.egg-info → seqbuild-0.0.74}/PKG-INFO +1 -1
- {seqbuild-0.0.72 → seqbuild-0.0.74}/pyproject.toml +1 -1
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/approximators.py +3 -1
- seqbuild-0.0.74/seqbuild/desi/cy_metric.py +179 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/differentials.py +4 -1
- seqbuild-0.0.74/seqbuild/face/chained_prng_cmp.py +100 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/cmd_proc.py +30 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/comm_lang.py +4 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/easy_gen_struct.py +36 -9
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/prng_bool_cmp.py +4 -1
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/prng_stats.py +132 -10
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commlang_guide.md +15 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sb_ui.py +3 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/ag_ext.py +2 -2
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/n2m_index.py +5 -2
- seqbuild-0.0.74/seqbuild/mini_dm/ngram_ext.py +169 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/afs_gen.py +18 -2
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/cs_gen.py +8 -2
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/gg_gen.py +3 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/mdr_gen.py +5 -2
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/optri_gen.py +1 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/rch_gen.py +21 -8
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/udls_gen.py +14 -4
- {seqbuild-0.0.72 → seqbuild-0.0.74/seqbuild.egg-info}/PKG-INFO +1 -1
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild.egg-info/SOURCES.txt +3 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/setup.py +1 -1
- {seqbuild-0.0.72 → seqbuild-0.0.74}/LICENSE.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/README.md +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/__init__.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/__init__.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/fraction.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/multi_metric.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/not_equals.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/nvec_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/prng_dec_delta.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/desi/seqcov_perm.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/__init__.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/cl_guide_parser.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/make_cmd.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_11.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_12error.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_13.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_14.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_15.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_16.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_17.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_18.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_19.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_20.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_21.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_22.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_23.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_24.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_25.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_26.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_27.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_28.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_29.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_30.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_31.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_32.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_33.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_34.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_41.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_42.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_afs.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_cshft.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_eight.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_fit22.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_five.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_four.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_gg.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_lcg_cmp.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_lcg_cmp2.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_lps.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_n2m.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_nine.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_one.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_pm.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_seven.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_six.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_ten.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_three.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commond_udls.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/commondeth.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/dummy_obj.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/example_command.md +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_base_screen.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_help_cmd.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_help_make.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_help_screen.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_load_c9.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_realtime_command.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/seqbuild_show_numbers.png +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/face/sample_script/tmp_file_that_no_one_should_use__HIOTRNGINRE.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/__init__.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/extraneous.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/idectree.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/idt_proc.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/intfactor.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/lcg_v2.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/lcg_v3.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/mdr_v2.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/mod_prng.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/modulo_ops.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/n2mvf_autogen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/pof_autogen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/poly_output_fitter_.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/prng_pw_op.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/process_seq.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/seq_struct.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/intigers/tvec.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/__init__.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/affine_fit_search.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/affine_io_fit.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/affine_ops.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/csrch.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/iseq.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/matfactor_eval.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/minmax_freq.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/n2m.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/n2m_function.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/ngram.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/nsfr.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/puc.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/mini_dm/sp_op.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/__init__.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/fit22_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/idt_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/lps_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/n2mv_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/pmulti_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/sb_crypt.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/shadow_gen.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/ssi_load.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild/seqgen/ssi_netop.py +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild.egg-info/dependency_links.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild.egg-info/requires.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/seqbuild.egg-info/top_level.txt +0 -0
- {seqbuild-0.0.72 → seqbuild-0.0.74}/setup.cfg +0 -0
|
@@ -186,8 +186,10 @@ class LPSValueOutputter(GenericIntSeqOp):
|
|
|
186
186
|
return
|
|
187
187
|
|
|
188
188
|
def update_points(self):
|
|
189
|
+
# NOTE: add ranged moduli over PRNG to ensure timely Lagrange Polynomial solve.
|
|
190
|
+
q = wrap_ranged_modulo_over_generator(self.px,[-100-2/3,100+1/3])
|
|
191
|
+
self.q = LPSValueOutputter.new_pointset(q,self.l_out)
|
|
189
192
|
|
|
190
|
-
self.q = LPSValueOutputter.new_pointset(self.px,self.l_out)
|
|
191
193
|
|
|
192
194
|
# assumes q is a proper set of points for
|
|
193
195
|
# fitting via <LagrangePolySolver>
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
from ..mini_dm.ngram_ext import *
|
|
2
|
+
from morebs2.seq_repr import *
|
|
3
|
+
from types import MethodType,FunctionType
|
|
4
|
+
from ..mini_dm.iseq import stdop_vec
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Used for Cycle Test, focused on qualities of forward permutations. Measures are
|
|
8
|
+
frequency-based on n-gram prefixes to m-gram suffixes of the next `num_iter` samples
|
|
9
|
+
from `prg`.
|
|
10
|
+
|
|
11
|
+
Important metrics per prefix:
|
|
12
|
+
[0] mcs_k, MCS k-complexity of the ordered concatenation of suffixes.
|
|
13
|
+
[1] cy_diff, mean cyclical kernel difference of ordered concatenation of suffixes.
|
|
14
|
+
[2] I_diff, set size for difference vector of prefix indices of occurrence.
|
|
15
|
+
[3] var_norm, normalized variance of suffix frequency.
|
|
16
|
+
|
|
17
|
+
For metrics [0] + [1], there are an additional four categories of scores:
|
|
18
|
+
seq -> ordered concatenation of literal suffixes,
|
|
19
|
+
set -> ordered concatenation of set form of suffixes,
|
|
20
|
+
valfreq -> ordered concatention of (suffix label,suffix frequency) pairs per suffix,
|
|
21
|
+
l-seq -> ordered concatenation of labelled suffixes.
|
|
22
|
+
"""
|
|
23
|
+
class CycleMetric:
|
|
24
|
+
|
|
25
|
+
def __init__(self,prg,num_iter:int,pre_size:int,post_size:int,cast_func=cr):
|
|
26
|
+
assert type(prg) in {MethodType,FunctionType}
|
|
27
|
+
assert num_iter > 0 and type(num_iter) == int
|
|
28
|
+
|
|
29
|
+
self.prg = prg
|
|
30
|
+
self.num_iter = num_iter
|
|
31
|
+
self.pre_size = pre_size
|
|
32
|
+
self.post_size = post_size
|
|
33
|
+
self.cast_func = cast_func
|
|
34
|
+
|
|
35
|
+
self.S = []
|
|
36
|
+
self.M_ = None
|
|
37
|
+
self.M = []
|
|
38
|
+
|
|
39
|
+
# prefix --> measure type --> (mcs_k, cy_diff)
|
|
40
|
+
self.prefix2mcs_map = dict()
|
|
41
|
+
|
|
42
|
+
# prefix --> (I_diff, var_norm)
|
|
43
|
+
self.prefix2score_map = dict()
|
|
44
|
+
|
|
45
|
+
self.preproc()
|
|
46
|
+
|
|
47
|
+
def preproc(self):
|
|
48
|
+
self.load_next_batch()
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
call this to update reference sequence to another
|
|
52
|
+
one, before calling method<process>.
|
|
53
|
+
"""
|
|
54
|
+
def load_next_batch(self,num_iter=None):
|
|
55
|
+
if type(num_iter) != type(None):
|
|
56
|
+
assert type(num_iter) == int and num_iter > 0
|
|
57
|
+
self.num_iter = num_iter
|
|
58
|
+
|
|
59
|
+
self.S.clear()
|
|
60
|
+
self.S = [self.cast_func(self.prg()) for _ in range(self.num_iter)]
|
|
61
|
+
|
|
62
|
+
if type(self.M_) != type(None):
|
|
63
|
+
self.M.append(self.M_)
|
|
64
|
+
|
|
65
|
+
self.M_ = SequencePrePostMap(self.S,self.pre_size,self.post_size)
|
|
66
|
+
self.M_.process()
|
|
67
|
+
|
|
68
|
+
self.prefix2score_map.clear()
|
|
69
|
+
for k in self.M_.M.keys():
|
|
70
|
+
self.prefix2score_map[k] = dict()
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
main method
|
|
74
|
+
"""
|
|
75
|
+
def process(self):
|
|
76
|
+
|
|
77
|
+
prefixes = set(self.M_.M.keys())
|
|
78
|
+
S = dict()
|
|
79
|
+
print("num prefixes: ",len(prefixes))
|
|
80
|
+
for p in prefixes:
|
|
81
|
+
print("processing: ",p)
|
|
82
|
+
P,d0,v0 = self.process_prefix(p)
|
|
83
|
+
self.prefix2mcs_map[p] = P
|
|
84
|
+
self.prefix2score_map[p] = (d0,v0)
|
|
85
|
+
print("")
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
[0] dict, measure type --> mean over prefixes
|
|
90
|
+
[1] mean of I_diff over prefixes
|
|
91
|
+
[2] mean of normed variance over prefixes
|
|
92
|
+
"""
|
|
93
|
+
def summarize(self):
|
|
94
|
+
D = dict()
|
|
95
|
+
for m in DEFAULT_CYMETRIC_SUFFIX_MEASURE_TYPES:
|
|
96
|
+
S = self.fetch_scores_by_type(m)
|
|
97
|
+
M = np.array(list(S.values()))
|
|
98
|
+
q = np.mean(M,axis=0)
|
|
99
|
+
if np.isnan(q[0]):
|
|
100
|
+
q[0] = float('inf')
|
|
101
|
+
D[m] = q
|
|
102
|
+
|
|
103
|
+
M = np.array(list(self.prefix2score_map.values()))
|
|
104
|
+
idiff_mean,nvar_mean = np.mean(M,axis=0)
|
|
105
|
+
return D,idiff_mean,nvar_mean
|
|
106
|
+
|
|
107
|
+
def fetch_scores_by_type(self,measure_type):
|
|
108
|
+
assert measure_type in DEFAULT_CYMETRIC_SUFFIX_MEASURE_TYPES
|
|
109
|
+
D = dict()
|
|
110
|
+
for k,v in self.prefix2mcs_map.items():
|
|
111
|
+
D[k] = v[measure_type]
|
|
112
|
+
return D
|
|
113
|
+
|
|
114
|
+
def process_prefix(self,prefix):
|
|
115
|
+
P = {}
|
|
116
|
+
for l in DEFAULT_CYMETRIC_SUFFIX_MEASURE_TYPES:
|
|
117
|
+
m_score,ck_score = self.mcs_complexity_at_prefix(prefix,l)
|
|
118
|
+
P[l] = (m_score,ck_score)
|
|
119
|
+
|
|
120
|
+
d0 = self.index_of_occurrence_difference_setsize_at_prefix(prefix)
|
|
121
|
+
v0 = self.normalized_variance_of_suffix_frequency_at_prefix(prefix)
|
|
122
|
+
return P,d0,v0
|
|
123
|
+
|
|
124
|
+
def index_of_occurrence_difference_setsize_at_prefix(self,prefix):
|
|
125
|
+
indices = sorted(self.M_.M[prefix].keys())
|
|
126
|
+
V = stdop_vec(np.array(indices),sub,np.float32)
|
|
127
|
+
l = len(set(V))
|
|
128
|
+
if l == 0: return float('inf')
|
|
129
|
+
return l
|
|
130
|
+
|
|
131
|
+
# NOTE: duplicate code?
|
|
132
|
+
def normalized_variance_of_suffix_frequency_at_prefix(self,prefix):
|
|
133
|
+
|
|
134
|
+
prefix_info = self.M_.key_to_seq_by_type(prefix,"valfreq")
|
|
135
|
+
frequencies = np.array([prefix_info[i] for i in range(1,len(prefix_info),2)])
|
|
136
|
+
|
|
137
|
+
m = np.mean(frequencies)
|
|
138
|
+
|
|
139
|
+
f2 = np.abs(frequencies - m)
|
|
140
|
+
mdiff = np.max(frequencies) - np.min(frequencies)
|
|
141
|
+
if mdiff == 0: return 0
|
|
142
|
+
|
|
143
|
+
return np.sum(f2) / (mdiff * len(f2))
|
|
144
|
+
|
|
145
|
+
"""
|
|
146
|
+
[0] MCS k-complexity by averaging the four:
|
|
147
|
+
- bool + contiguous|best + median|most frequent
|
|
148
|
+
[1] best cyclical kernel score
|
|
149
|
+
"""
|
|
150
|
+
def mcs_complexity_at_prefix(self,prefix,measure_type):
|
|
151
|
+
assert measure_type in DEFAULT_CYMETRIC_SUFFIX_MEASURE_TYPES
|
|
152
|
+
|
|
153
|
+
prefix_info = self.M_.key_to_seq_by_type(prefix,measure_type)
|
|
154
|
+
##print("PREFIX: ",prefix_info)
|
|
155
|
+
## print("MCS LEN: ",len(prefix_info))
|
|
156
|
+
ms = MCSSearch(prefix_info,self.cast_func)
|
|
157
|
+
ms.search()
|
|
158
|
+
|
|
159
|
+
m_score = self.mcs_complexity_at_prefix_(ms,prefix,measure_type)
|
|
160
|
+
|
|
161
|
+
ck_score = ms.mean_cyclical_kernel_score()
|
|
162
|
+
return m_score,ck_score
|
|
163
|
+
|
|
164
|
+
def mcs_complexity_at_prefix_(self,ms,prefix,measure_type):
|
|
165
|
+
assert type(ms) == MCSSearch
|
|
166
|
+
|
|
167
|
+
d0 = ms.default_kcomplexity(diff_type="bool",\
|
|
168
|
+
diff_type2="best",basis="median")
|
|
169
|
+
|
|
170
|
+
d1 = ms.default_kcomplexity(diff_type="bool",\
|
|
171
|
+
diff_type2="contiguous",basis="median")
|
|
172
|
+
|
|
173
|
+
d2 = ms.default_kcomplexity(diff_type="bool",\
|
|
174
|
+
diff_type2="best",basis="most frequent")
|
|
175
|
+
|
|
176
|
+
d3 = ms.default_kcomplexity(diff_type="bool",\
|
|
177
|
+
diff_type2="contiguous",basis="most frequent")
|
|
178
|
+
|
|
179
|
+
return (d0 + d1 + d2 + d3) / (4 * len(self.S))
|
|
@@ -75,7 +75,10 @@ class PIDValueOutputter(GenericIntSeqOp):
|
|
|
75
75
|
stat = (self.adder_i % self.fvec_frequency) == 0
|
|
76
76
|
|
|
77
77
|
if stat:
|
|
78
|
-
|
|
78
|
+
try:
|
|
79
|
+
self.pic.modulate_dcurve_of_point(x)
|
|
80
|
+
except:
|
|
81
|
+
print("...strange...")
|
|
79
82
|
|
|
80
83
|
q = self.pic.differential_at(x,lps_first=True)
|
|
81
84
|
self.adder_i += 1
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from .prng_stats import *
|
|
2
|
+
from .make_cmd import MAIN_method_for_object
|
|
3
|
+
|
|
4
|
+
class ChainedPRNGComparator:
|
|
5
|
+
|
|
6
|
+
def __init__(self,prng_struct_seq,prg_varname,ngram_info,partition_size,\
|
|
7
|
+
output_prg_range=None,do_embed_generators:bool=True):
|
|
8
|
+
|
|
9
|
+
if type(output_prg_range) != type(None):
|
|
10
|
+
assert is_valid_range(output_prg_range,True,False) or is_valid_range(output_prg_range,False,False)
|
|
11
|
+
assert len(prng_struct_seq) > 1
|
|
12
|
+
assert type(do_embed_generators) == bool
|
|
13
|
+
|
|
14
|
+
self.prng_struct_seq = prng_struct_seq
|
|
15
|
+
self.prg_varname = prg_varname
|
|
16
|
+
self.ngram_info = ngram_info
|
|
17
|
+
self.psize = partition_size
|
|
18
|
+
self.output_prg_range = output_prg_range
|
|
19
|
+
self.do_embed = do_embed_generators
|
|
20
|
+
|
|
21
|
+
self.pstat_seq = None
|
|
22
|
+
self.preproc()
|
|
23
|
+
self.processed = False
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
def preproc(self):
|
|
27
|
+
|
|
28
|
+
# set every prng struct's parameter `prg_varname` to the previous prng.
|
|
29
|
+
if self.do_embed:
|
|
30
|
+
for i in range(1,len(self.prng_struct_seq)):
|
|
31
|
+
q0 = deepcopy(self.prng_struct_seq[i-1])
|
|
32
|
+
prg = MAIN_method_for_object(q0)
|
|
33
|
+
setattr(self.prng_struct_seq[i],self.prg_varname,prg)
|
|
34
|
+
|
|
35
|
+
prgs = [MAIN_method_for_object(p) for p in self.prng_struct_seq]
|
|
36
|
+
|
|
37
|
+
# apply modulii range if not None
|
|
38
|
+
if type(self.output_prg_range) != type(None):
|
|
39
|
+
prgs = [wrap_ranged_modulo_over_generator(p,self.output_prg_range) for p in \
|
|
40
|
+
prgs]
|
|
41
|
+
|
|
42
|
+
# initialize PRNGStats for every generator
|
|
43
|
+
self.pstat_seq = [PRNGStats(p,self.ngram_info,self.psize) for p in prgs]
|
|
44
|
+
|
|
45
|
+
def run(self):
|
|
46
|
+
for (i,x) in enumerate(self.pstat_seq):
|
|
47
|
+
print("* running input prng #{}".format(i))
|
|
48
|
+
x.run()
|
|
49
|
+
self.processed = True
|
|
50
|
+
|
|
51
|
+
# NOTE: duplicate code with <PRNGIOStats.cmp_matrix>.
|
|
52
|
+
def cmp_matrix(self,metric_numbers:set = {1,2,3,4,5,6,7}):
|
|
53
|
+
if not self.processed:
|
|
54
|
+
print("[!] comparator has not processed all PRNGs")
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
M = np.zeros((len(self.prng_struct_seq),len(self.prng_struct_seq))) + np.nan
|
|
58
|
+
|
|
59
|
+
for i in range(len(self.pstat_seq) - 1):
|
|
60
|
+
for j in range(i+1,len(self.pstat_seq)):
|
|
61
|
+
b = self.boolcmp_stats(j,i,metric_numbers)
|
|
62
|
+
M[i,j] = b
|
|
63
|
+
return M
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# NOTE: duplicate code of method<PRNGIOStats.boolcmp_stats>
|
|
67
|
+
"""
|
|
68
|
+
return:
|
|
69
|
+
1(more random)|-1(less random)|0(equally random)
|
|
70
|
+
"""
|
|
71
|
+
def boolcmp_stats(self,i0,i1,metric_numbers:set):
|
|
72
|
+
|
|
73
|
+
G0,G1 = self.pstat_seq[i0],self.pstat_seq[i1]
|
|
74
|
+
|
|
75
|
+
q0,c0 = G0.latest_results()
|
|
76
|
+
q1,c1 = G1.latest_results()
|
|
77
|
+
|
|
78
|
+
return is_PRNG_more_QC_random((q0,c0),(q1,c1),metric_numbers)
|
|
79
|
+
|
|
80
|
+
"""
|
|
81
|
+
uses a unique copy of `prg` to generate every struct in `struct_name_list`
|
|
82
|
+
(no embedded generators). Then uses a <ChainedPRNGComparator> to produce a
|
|
83
|
+
cumulative comparison matrix over `num_iter` segments.
|
|
84
|
+
"""
|
|
85
|
+
def prg_to_chained_PRNG_cmp_matrix(prg,struct_name_list,ngram_info=[8],partition_size=5,\
|
|
86
|
+
output_prg_range=[-50000,50000],num_iter=1,include_source_prg_in_cmp:bool=False):
|
|
87
|
+
|
|
88
|
+
a = int(include_source_prg_in_cmp)
|
|
89
|
+
M = np.zeros((len(struct_name_list) + a,len(struct_name_list) + a))
|
|
90
|
+
S = [one_P_random_struct(l,deepcopy(prg)) for l in struct_name_list]
|
|
91
|
+
if include_source_prg_in_cmp: S.insert(0,prg)
|
|
92
|
+
|
|
93
|
+
X = ChainedPRNGComparator(S,"prg",ngram_info,partition_size,output_prg_range,do_embed_generators = False)
|
|
94
|
+
|
|
95
|
+
for _ in range(num_iter):
|
|
96
|
+
X.run()
|
|
97
|
+
q = X.cmp_matrix()
|
|
98
|
+
print("{}: {}".format(_,q))
|
|
99
|
+
M = M + q
|
|
100
|
+
return M
|
|
@@ -7,6 +7,7 @@ from .make_cmd import *
|
|
|
7
7
|
from morebs2.matrix_methods import cr
|
|
8
8
|
from ..mini_dm.nsfr import *
|
|
9
9
|
from ..intigers.mod_prng import *
|
|
10
|
+
from ..desi.cy_metric import *
|
|
10
11
|
|
|
11
12
|
import io
|
|
12
13
|
import pickle
|
|
@@ -375,6 +376,35 @@ def CHAINTEST_proc(splitstr_cmd,var_map):
|
|
|
375
376
|
|
|
376
377
|
return q2
|
|
377
378
|
|
|
379
|
+
def CYCLETEST_proc(splitstr_cmd,var_map):
|
|
380
|
+
assert splitstr_cmd[0] == "cycletest"
|
|
381
|
+
|
|
382
|
+
assert splitstr_cmd[1] in var_map
|
|
383
|
+
G = MAIN_method_for_object(var_map[splitstr_cmd[1]])
|
|
384
|
+
|
|
385
|
+
assert splitstr_cmd[2] == "with"
|
|
386
|
+
|
|
387
|
+
qx = splitstr_cmd[3].split(',')
|
|
388
|
+
assert len(qx) == 3
|
|
389
|
+
|
|
390
|
+
num_iter = int(qx[0])
|
|
391
|
+
pre_size = int(qx[1])
|
|
392
|
+
post_size = int(qx[2])
|
|
393
|
+
|
|
394
|
+
C = CycleMetric(G,num_iter,pre_size,post_size)
|
|
395
|
+
|
|
396
|
+
C.process()
|
|
397
|
+
S,s0,s1 = C.summarize()
|
|
398
|
+
|
|
399
|
+
keys = sorted(S.keys())
|
|
400
|
+
|
|
401
|
+
Q = ""
|
|
402
|
+
for k in keys:
|
|
403
|
+
Q += k + " : mcs_k= {},cy_diff= {}\n".format(S[k][0],S[k][1])
|
|
404
|
+
Q += "idiff_mean: {}\n".format(s0)
|
|
405
|
+
Q += "nvar_mean: {}\n".format(s1)
|
|
406
|
+
return Q
|
|
407
|
+
|
|
378
408
|
"""
|
|
379
409
|
reads a file containing a numerical sequence
|
|
380
410
|
---
|
|
@@ -1102,22 +1102,31 @@ class TimeBasedCommLangFileGenerator:
|
|
|
1102
1102
|
DEFAULT_TBCLF_TMP_FILE_PATH = os.path.join(BASE_COMM_LANG_FOLDER,"tmp_file_that_no_one_should_use__HIOTRNGINRE.txt")
|
|
1103
1103
|
|
|
1104
1104
|
def one_T_random_struct(struct_name,tmp_filepath=DEFAULT_TBCLF_TMP_FILE_PATH):
|
|
1105
|
+
return one_X_random_struct(struct_name,None,tmp_filepath)
|
|
1106
|
+
|
|
1107
|
+
"""
|
|
1108
|
+
outputs a PRNG generated by PRNG `prg`
|
|
1109
|
+
"""
|
|
1110
|
+
def one_P_random_struct(struct_name,prg,tmp_filepath=DEFAULT_TBCLF_TMP_FILE_PATH):
|
|
1111
|
+
return one_X_random_struct(struct_name,prg,tmp_filepath)
|
|
1112
|
+
|
|
1113
|
+
def one_X_random_struct(struct_name,prg,tmp_filepath=DEFAULT_TBCLF_TMP_FILE_PATH):
|
|
1105
1114
|
|
|
1106
1115
|
q = None
|
|
1107
1116
|
|
|
1108
1117
|
while not q:
|
|
1109
|
-
q =
|
|
1118
|
+
q = one_X_random_struct_(struct_name,prg,tmp_filepath)
|
|
1110
1119
|
return q
|
|
1111
1120
|
|
|
1112
1121
|
"""
|
|
1113
1122
|
outputs a time-based pseudo-random generated PRNG Python object
|
|
1114
1123
|
"""
|
|
1115
|
-
def
|
|
1116
|
-
|
|
1124
|
+
def one_X_random_struct(struct_name,prg,tmp_filepath=DEFAULT_TBCLF_TMP_FILE_PATH):
|
|
1117
1125
|
assert struct_name in DEFAULT_TBCLF_STRUCT_NAMES
|
|
1126
|
+
is_gen_time = type(prg) == type(None)
|
|
1118
1127
|
|
|
1119
1128
|
base_gen_name = "rxx"
|
|
1120
|
-
use_prng_for_prng_pr = 0.5
|
|
1129
|
+
use_prng_for_prng_pr = 0.5 if is_gen_time == "t" else 0.
|
|
1121
1130
|
vector_files = []
|
|
1122
1131
|
comm_lang_files = []
|
|
1123
1132
|
consistent_prng_output = False
|
|
@@ -1125,10 +1134,14 @@ def one_T_random_struct_(struct_name,tmp_filepath=DEFAULT_TBCLF_TMP_FILE_PATH):
|
|
|
1125
1134
|
|
|
1126
1135
|
tbclf = TimeBasedCommLangFileGenerator(tmp_filepath,base_gen_name,use_prng_for_prng_pr,\
|
|
1127
1136
|
vector_files,comm_lang_files,consistent_prng_output,verbose)
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1137
|
+
|
|
1138
|
+
if is_gen_time == "t":
|
|
1139
|
+
for _ in range(3):
|
|
1140
|
+
S,g = tbclf.generate_CL_LCG_bunch()
|
|
1141
|
+
tbclf.update_CL_file(S)
|
|
1142
|
+
else:
|
|
1143
|
+
assert type(prg) in {MethodType,FunctionType}
|
|
1144
|
+
tbclf.pdd = prg
|
|
1132
1145
|
|
|
1133
1146
|
S,g = tbclf.generate_one_struct_(struct_name)
|
|
1134
1147
|
tbclf.update_CL_file(S)
|
|
@@ -1137,4 +1150,18 @@ def one_T_random_struct_(struct_name,tmp_filepath=DEFAULT_TBCLF_TMP_FILE_PATH):
|
|
|
1137
1150
|
q = tbclf.clp.vartable[g]
|
|
1138
1151
|
tbclf.close()
|
|
1139
1152
|
|
|
1140
|
-
return q
|
|
1153
|
+
return q
|
|
1154
|
+
|
|
1155
|
+
#-------------------------------------------------------
|
|
1156
|
+
|
|
1157
|
+
def chain_generate_P_random_structs(starting_prg,struct_name_list):
|
|
1158
|
+
prngs = []
|
|
1159
|
+
q = deepcopy(starting_prg)
|
|
1160
|
+
|
|
1161
|
+
for x in struct_name_list:
|
|
1162
|
+
q2 = one_P_random_struct(x,q)
|
|
1163
|
+
q = deepcopy(MAIN_method_for_object(q2))
|
|
1164
|
+
|
|
1165
|
+
prngs.append(q2)
|
|
1166
|
+
|
|
1167
|
+
return prngs
|
|
@@ -10,7 +10,7 @@ repeat on the values of these two tests:
|
|
|
10
10
|
categorical entropy: 0 <= x <= 1
|
|
11
11
|
K-complexity of 1st order ternary difference
|
|
12
12
|
K-complexity of 2nd order ternary difference
|
|
13
|
-
|
|
13
|
+
complexity of (sequence - most common subsequence)
|
|
14
14
|
[1] factor modular k-complexity:
|
|
15
15
|
factor -> (1st order k-complexity, 2nd order k-complexity)
|
|
16
16
|
[2] element -> frequency map
|
|
@@ -54,6 +54,9 @@ class QCInfo:
|
|
|
54
54
|
|
|
55
55
|
self.c = qc[1]
|
|
56
56
|
|
|
57
|
+
def retrieve_all(self):
|
|
58
|
+
return {t:self.retrieve(t) for t in SCORE_TERMS}
|
|
59
|
+
|
|
57
60
|
def retrieve(self,term):
|
|
58
61
|
assert term in SCORE_TERMS
|
|
59
62
|
|
|
@@ -5,7 +5,6 @@ from .prng_bool_cmp import *
|
|
|
5
5
|
|
|
6
6
|
DEFAULT_QUALTEST_SEGMENT_LENGTH = 200
|
|
7
7
|
DEFAULT_CHAINTEST_SEGMENT_LENGTH = 1000
|
|
8
|
-
DEFAULT_CHAINTEST_RADIUS = 0.5
|
|
9
8
|
|
|
10
9
|
"""
|
|
11
10
|
Method<run> conducts QUALTEST and CHAINTEST for their respective
|
|
@@ -45,9 +44,9 @@ class PRNGStats:
|
|
|
45
44
|
return
|
|
46
45
|
|
|
47
46
|
def run(self):
|
|
48
|
-
|
|
49
47
|
self.qtest()
|
|
50
48
|
self.ctest()
|
|
49
|
+
print("============================================================")
|
|
51
50
|
return
|
|
52
51
|
|
|
53
52
|
def latest_results(self):
|
|
@@ -102,10 +101,13 @@ class PRNGStats:
|
|
|
102
101
|
Q2 = self.cqueue
|
|
103
102
|
s = DEFAULT_QUALTEST_SEGMENT_LENGTH
|
|
104
103
|
|
|
104
|
+
print("populating {}->{}".format(len(Q),s))
|
|
105
|
+
|
|
105
106
|
while len(Q) < s:
|
|
106
107
|
x = self.prg()
|
|
107
108
|
Q.append(x)
|
|
108
109
|
Q2.append(x)
|
|
110
|
+
print("done populating")
|
|
109
111
|
|
|
110
112
|
'''
|
|
111
113
|
A comparator class for input PRNGs, of `input_prg_list`, when they are each used as a
|
|
@@ -129,7 +131,7 @@ boolean metrics from file<face.prng_bool_cmp> to use), these comparisons output
|
|
|
129
131
|
class PRNGIOStats:
|
|
130
132
|
|
|
131
133
|
def __init__(self,input_prg_list,input_prg_varname,output_prg_struct,ngram_info,\
|
|
132
|
-
partition_size,absdiff:bool=True):
|
|
134
|
+
partition_size,absdiff:bool=True,output_prg_range=None,collect_variance_over_runs:bool=False):
|
|
133
135
|
|
|
134
136
|
assert len(input_prg_list) > 0
|
|
135
137
|
|
|
@@ -137,36 +139,132 @@ class PRNGIOStats:
|
|
|
137
139
|
assert type(x) in {MethodType,FunctionType}
|
|
138
140
|
assert type(absdiff) == bool
|
|
139
141
|
|
|
142
|
+
if type(output_prg_range) != type(None):
|
|
143
|
+
assert is_valid_range(output_prg_range,True,False) or \
|
|
144
|
+
is_valid_range(output_prg_range,False,False)
|
|
145
|
+
|
|
146
|
+
assert type(collect_variance_over_runs) == bool
|
|
147
|
+
|
|
140
148
|
self.input_prg_list = input_prg_list
|
|
141
149
|
self.input_prg_varname = input_prg_varname
|
|
142
150
|
self.output_prg_struct = output_prg_struct
|
|
151
|
+
self.cvar_over_runs = collect_variance_over_runs
|
|
143
152
|
self.ngram_info = ngram_info
|
|
144
153
|
self.psize = partition_size
|
|
145
154
|
self.absdiff = absdiff
|
|
146
155
|
|
|
147
156
|
self.input_prng_stats = []
|
|
148
157
|
self.output_prng_stats = []
|
|
158
|
+
self.output_prg_range = output_prg_range
|
|
159
|
+
|
|
160
|
+
# index -> score term -> list of values over runs
|
|
161
|
+
self.input_prng_summary = defaultdict(None)
|
|
162
|
+
self.output_prng_summary = defaultdict(None)
|
|
149
163
|
self.preproc()
|
|
164
|
+
|
|
150
165
|
return
|
|
151
166
|
|
|
152
167
|
def preproc(self):
|
|
153
|
-
for x in self.input_prg_list:
|
|
154
|
-
G0 = PRNGStats(x,deepcopy(self.ngram_info),self.psize)
|
|
155
|
-
self.input_prng_stats.append(G0)
|
|
168
|
+
for (i,x) in enumerate(self.input_prg_list):
|
|
156
169
|
|
|
157
170
|
G = deepcopy(self.output_prg_struct)
|
|
158
171
|
setattr(G,self.input_prg_varname,deepcopy(x))
|
|
159
|
-
|
|
160
|
-
|
|
172
|
+
|
|
173
|
+
x_ = x
|
|
174
|
+
Q = deepcopy(G.__next__)
|
|
175
|
+
if type(self.output_prg_range) != type(None):
|
|
176
|
+
x_ = wrap_ranged_modulo_over_generator(x_,self.output_prg_range)
|
|
177
|
+
Q = wrap_ranged_modulo_over_generator(Q,self.output_prg_range)
|
|
178
|
+
|
|
179
|
+
G0 = PRNGStats(x_,deepcopy(self.ngram_info),self.psize)
|
|
180
|
+
self.input_prng_stats.append(G0)
|
|
181
|
+
|
|
182
|
+
G1 = PRNGStats(Q,deepcopy(self.ngram_info),self.psize)
|
|
183
|
+
self.output_prng_stats.append(G1)
|
|
184
|
+
|
|
185
|
+
self.input_prng_summary[i] = defaultdict(list)
|
|
186
|
+
self.output_prng_summary[i] = defaultdict(list)
|
|
187
|
+
|
|
188
|
+
def update_summary(self,index,is_input_prg:bool):
|
|
189
|
+
assert type(is_input_prg) == bool
|
|
190
|
+
assert 0 <= index < len(self.input_prg_list)
|
|
191
|
+
|
|
192
|
+
x = self.input_prng_stats[index] if is_input_prg else \
|
|
193
|
+
self.output_prng_stats[index]
|
|
194
|
+
|
|
195
|
+
q0,q1 = x.latest_results()
|
|
196
|
+
qc = QCInfo((q0,q1))
|
|
197
|
+
|
|
198
|
+
D = qc.retrieve_all()
|
|
199
|
+
|
|
200
|
+
D2 = self.input_prng_summary[index] if is_input_prg else \
|
|
201
|
+
self.output_prng_summary[index]
|
|
202
|
+
|
|
203
|
+
for k,v in D.items():
|
|
204
|
+
D2[k].append(v)
|
|
161
205
|
|
|
162
206
|
def run(self):
|
|
163
207
|
for (i,x) in enumerate(self.input_prng_stats):
|
|
164
208
|
print("* running input prng #{}".format(i))
|
|
165
209
|
x.run()
|
|
210
|
+
|
|
211
|
+
if self.cvar_over_runs: self.update_summary(i,True)
|
|
166
212
|
|
|
167
213
|
for (i,y) in enumerate(self.output_prng_stats):
|
|
168
214
|
print("* running output prng #{}".format(i))
|
|
169
|
-
y.run()
|
|
215
|
+
y.run()
|
|
216
|
+
|
|
217
|
+
if self.cvar_over_runs: self.update_summary(i,False)
|
|
218
|
+
|
|
219
|
+
"""
|
|
220
|
+
Compares the intra-variance between two PRNGs.
|
|
221
|
+
|
|
222
|
+
index_type_pair0 := (PRNG index, ?is input PRNG?)
|
|
223
|
+
index_type_pair1 := (PRNG index, ?is input PRNG?)
|
|
224
|
+
"""
|
|
225
|
+
def cmp_var_over_runs(self,index_type_pair0,index_type_pair1):
|
|
226
|
+
assert len(index_type_pair0) == len(index_type_pair1) == 2
|
|
227
|
+
|
|
228
|
+
G0 = self.input_prng_summary[index_type_pair0[0]] if \
|
|
229
|
+
index_type_pair0[1] else self.output_prng_summary[index_type_pair0[0]]
|
|
230
|
+
G1 = self.input_prng_summary[index_type_pair1[0]] if \
|
|
231
|
+
index_type_pair1[1] else self.output_prng_summary[index_type_pair1[0]]
|
|
232
|
+
|
|
233
|
+
var0 = {k:np.var(v) for k,v in G0.items()}
|
|
234
|
+
var1 = {k:np.var(v) for k,v in G1.items()}
|
|
235
|
+
|
|
236
|
+
D = dict()
|
|
237
|
+
|
|
238
|
+
for k,v in var0.items():
|
|
239
|
+
r = to_trinary_relation(v,var1[k])
|
|
240
|
+
D[k] = r
|
|
241
|
+
|
|
242
|
+
print("** variance comparison")
|
|
243
|
+
Q = sorted(SCORE_TERMS)
|
|
244
|
+
for q in Q:
|
|
245
|
+
print("{} -> {}".format(q,D[q]))
|
|
246
|
+
|
|
247
|
+
return to_trinary_relation_v2(sum(list(D.values())),None,True,False)
|
|
248
|
+
|
|
249
|
+
# TODO: test
|
|
250
|
+
def cmp_matrix(self,cmp_type:str,metric_numbers:set=None):
|
|
251
|
+
assert cmp_type in {"i","o","io"}
|
|
252
|
+
|
|
253
|
+
l = len(self.input_prg_list)
|
|
254
|
+
M = np.zeros((l,l)) + np.nan
|
|
255
|
+
|
|
256
|
+
if cmp_type == "i":
|
|
257
|
+
F = self.input_cmp
|
|
258
|
+
elif cmp_type == "o":
|
|
259
|
+
F = self.output_cmp
|
|
260
|
+
else:
|
|
261
|
+
F = self.pairwise_io_cmp
|
|
262
|
+
|
|
263
|
+
for i in range(l - 1):
|
|
264
|
+
for j in range(i+1,l):
|
|
265
|
+
c = F(j,i,metric_numbers)
|
|
266
|
+
M[i,j] = c
|
|
267
|
+
return M
|
|
170
268
|
|
|
171
269
|
"""
|
|
172
270
|
input PRNG#0 - input PRNG#1
|
|
@@ -267,4 +365,28 @@ class PRNGIOStats:
|
|
|
267
365
|
q0,c0 = G0.latest_results()
|
|
268
366
|
q1,c1 = G1.latest_results()
|
|
269
367
|
|
|
270
|
-
return is_PRNG_more_QC_random((q0,c0),(q1,c1),metric_numbers)
|
|
368
|
+
return is_PRNG_more_QC_random((q0,c0),(q1,c1),metric_numbers)
|
|
369
|
+
|
|
370
|
+
def rank_prng_cmp_matrix(M,verbose=True):
|
|
371
|
+
assert len(M.shape) == 2
|
|
372
|
+
assert M.shape[0] == M.shape[1]
|
|
373
|
+
|
|
374
|
+
M_ = deepcopy(M)
|
|
375
|
+
M_[np.isnan(M_)] = 0.
|
|
376
|
+
|
|
377
|
+
D = []
|
|
378
|
+
|
|
379
|
+
for i in range(M_.shape[0]):
|
|
380
|
+
s0 = np.sum(M_[:,i])
|
|
381
|
+
s1 = np.sum(M_[i,:])
|
|
382
|
+
D.append((i,s0 - s1))
|
|
383
|
+
|
|
384
|
+
D = sorted(D,key=lambda x:x[1],reverse = True)
|
|
385
|
+
I = [d[0] for d in D]
|
|
386
|
+
|
|
387
|
+
for i in range(M_.shape[0]):
|
|
388
|
+
x = I.index(i)
|
|
389
|
+
y = D[x][1]
|
|
390
|
+
if verbose: print("index {} -> {} -> {}".format(i,x,y))
|
|
391
|
+
|
|
392
|
+
return D
|