<jupyter_start><jupyter_text>Sampling of strong times  I. The strong stationary time T<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from strong_stationary_times import core, sampling

def sample(sampler, list_M, n):
    results = []
    #
    for M in list_M:
        A = np.zeros( shape=(M,M), dtype=int )
        # Initialization with one element per fiber
        # for i in range(M):
        #    A[i,i] = 1
        # Initialization with only one element in only one fiber
        A[1,1] = 1
        samples = np.array( [sampler(A, debug=False) for i in range(1,n)] )
        print("M: ", M)
        mean = np.mean(samples)
        std  = np.std(samples)
        result = {
            "M"   : M,
            "n"   : n,
            "mean": mean,
            "std" : std
        }
        results.append(result)
        print("Result: ", result)
        plt.hist(Ts/(M*M), bins=15)
        plt.show()
    return results
n      = 100            # number of iid samples
list_M = [5, 7, 9, 11, 13, 15, 17]
#list_M = [5, 7]
results = sample( sampler=sampling.sample_T, list_M=list_M, n=n)
# Plot 
means = np.array( [res['mean'] for res in results])
stds  = np.array( [res['std'] for res in results] )
ic1   = means + 1.96*stds/np.sqrt(n)
ic2   = means - 1.96*stds/np.sqrt(n)
plt.plot(list_M, np.log(means)/np.log(list_M), '*')
plt.plot(list_M, np.log(ic1)/np.log(list_M), '--', label="upper confidence interval")
plt.plot(list_M, np.log(ic2)/np.log(list_M), '--', label="lower confidence interval")
plt.legend()
plt.xlabel("M")
plt.ylabel("log Mean / log M")
plt.ylim(0, 4)
plt.savefig("T_log_mean_vs_M.png")<jupyter_output><empty_output><jupyter_text>II. The stopping time S<jupyter_code>n      = 100            # number of iid samples
list_M = [5, 7, 9, 11, 13, 15, 17]
#list_M = [5, 7]
results = sample( sampler=sampling.sample_S, list_M=list_M, n=n)
# Plot 
means = np.array( [res['mean'] for res in results])
stds  = np.array( [res['std'] for res in results] )
ic1   = means + 1.96*stds/np.sqrt(n)
ic2   = means - 1.96*stds/np.sqrt(n)
plt.plot(list_M, np.log(means)/np.log(list_M), '*')
plt.plot(list_M, np.log(ic1)/np.log(list_M), '--', label="upper confidence interval")
plt.plot(list_M, np.log(ic2)/np.log(list_M), '--', label="lower confidence interval")
plt.legend()
plt.xlabel("M")
plt.ylabel("log Mean / log M")
plt.ylim(0, 4)
plt.savefig("S_log_mean_vs_M.png")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16728624535315986, 'fraction_numerical': 0.026022304832713755, 'mean_word_length': 3.0366666666666666, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '487364', 'license': 'MIT', 'n_tokens_mistral': 1011, 'n_tokens_neox': 941, 'n_words': 220, 'path': 'ipynb/StrongTimes.ipynb', 'repo_name': 'redachhaibi/StrongStationaryTimes', 'size': '2421'}