File indexing completed on 2026-04-09 07:49:21
0001
0002 """
0003 sseq_index_test.py : just for the NumPy statistical methods
0004 ==============================================================
0005
0006 Need this python despite most of comparison done in C++
0007 as getting chi2 cdf in C++ is too involved
0008
0009
0010 1. load persisted c2 info from $FOLD
0011 2. do statistical null-hyp calc and report
0012
0013 null-hyp consistent means there is no significant difference between
0014 the frequency counts in the A and B samples at a certain confidence
0015 level (normally 5%)
0016
0017 """
0018
0019 import numpy as np
0020 from opticks.ana.fold import Fold
0021 from opticks.ana.nbase import chi2_pvalue
0022
0023
0024 if __name__ == '__main__':
0025 print("[sseq_index_test.py\n")
0026
0027 f = Fold.Load(symbol="f")
0028 print(repr(f))
0029
0030 c2 = f.sseq_index_ab_chi2
0031 print(c2)
0032
0033 c2sum = c2[0]
0034 c2n = c2[1]
0035 c2cut = c2[2]
0036
0037 c2per = c2sum/c2n
0038
0039 c2pv = chi2_pvalue( c2sum, int(c2n) )
0040 c2pvm = "> 0.05 : null-hyp " if c2pv > 0.05 else "< 0.05 : NOT:null-hyp "
0041 c2pvd = "pv[%4.3f,%s] " % (c2pv, c2pvm)
0042
0043 c2desc = "c2sum/c2n:c2per(C2CUT) %5.2f/%d:%5.3f (%2d) %s" % ( c2sum, int(c2n), c2per, c2cut, c2pvd )
0044 c2label = "c2sum : %10.4f c2n : %10.4f c2per: %10.4f C2CUT: %4d " % ( c2sum, c2n, c2per, c2cut )
0045
0046 print(c2desc)
0047 print(c2label)
0048 print("]sseq_index_test.py\n")
0049 pass