<jupyter_start><jupyter_text>considerations on significance<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import chi2
from scipy.special import ndtri
ndtri(chi2.cdf(10., 1.))
def s_sqrt(s, b):
    """
    significance per sqrt(time) from 
    Bityukov and Krasnikov (1998)
    https://www.worldscientific.com/doi/epdf/10.1142/S0217732398003442
    """
    return 2. * (np.sqrt(s + b) - np.sqrt(b))
def s_lnl(s,b):
    """
    significance from likelihood ratio
    """
    return 2. * ((b + s) * np.log(b + s) - (b + s) * np.log(b) - s)
s = np.logspace(-8., -3., 6)
print(s)
b = np.logspace(-8., -1., 100)
ss, bb = np.meshgrid(s, b, indexing='ij')
s1 = s_sqrt(ss, bb)
s2 = s_lnl(ss, bb)
tobs = 20. * 3600. * 24.
for i_s, s_i in enumerate(s):
    plt.loglog(b, s1[i_s] * np.sqrt(tobs), label=f'Sqrt S, $N_s$ = {s_i:.1e}', ls='--', color=f'C{i_s}')
    
    plt.loglog(b, np.sqrt(s2[i_s] * tobs), label=f'ln S, $N_s$ = {s_i:.1e}', ls='-', color=f'C{i_s}')
    plt.loglog(b, ndtri(chi2.cdf(s2[i_s] * tobs, 1.)), ls=':', color=f'C{i_s}')
plt.axhline(5., color='k', ls=":")
plt.legend(ncol=2, fontsize='x-small')
#plt.grid(which='both')
plt.xlabel("$N_b$")
plt.ylabel("$S$")
for i_s, s_i in enumerate(s):
    plt.loglog(b, s1[i_s] * np.sqrt(tobs), label=f'Sqrt S, $N_s$ = {s_i:.1e}', ls='--', color=f'C{i_s}')
    
    plt.loglog(b, np.sqrt(s2[i_s] * tobs), label=f'ln S, $N_s$ = {s_i:.1e}', ls='-', color=f'C{i_s}')
    plt.loglog(b, ndtri(chi2.cdf(s2[i_s] * tobs, 1.)), ls=':', color=f'C{i_s}')
plt.axhline(5., color='k', ls=":")
#plt.legend(ncol=2, fontsize='x-small')
plt.axis([1e-8, 1e-5, 3., 15.])
plt.grid(which='both')
plt.xlabel("$N_b$")
plt.ylabel("$S$")<jupyter_output><empty_output><jupyter_text>derivative<jupyter_code>dS_db = 1. / np.sqrt(ss + bb) - 1. / np.sqrt(bb)
dS_ds = 1. / np.sqrt(ss + bb)
for i_s, s_i in enumerate(s):
    plt.loglog(b, np.abs(dS_db[i_s]), label=f'$|dS/dN_b|, N_s$ = {s_i:.1e}', ls='-', color=f'C{i_s}')
    
    plt.loglog(b, np.abs(dS_ds[i_s]), label=f'$|dS/dN_s|, N_s$ = {s_i:.1e}', ls='--', color=f'C{i_s}')
    
plt.legend(ncol=2, fontsize='x-small')
plt.ylim(1, 1e5)
plt.xlabel("$N_b$")
plt.ylabel("|Derivative|")
plt.grid(which='major')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24977698483496877, 'fraction_numerical': 0.03791257805530776, 'mean_word_length': 4.168202764976958, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '120598', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1135, 'n_words': 190, 'path': 'notebooks/Considerations_on_significance.ipynb', 'repo_name': 'me-manu/fastespy', 'size': '2242'}