<jupyter_start><jupyter_text>Let us load the team record data and obtain the record profiles for each team. The profiles will be passed to the DFA function.<jupyter_code>df=pd.read_csv(inputFile)
profileDf=df.subtract(df.mean()).cumsum()<jupyter_output><empty_output><jupyter_text>Examine a few team record profiles.<jupyter_code>plt.figure()
plt.plot(profileDf["LAL"],label="LAL")
plt.plot(profileDf["CHI"],label="CHI")
plt.plot(profileDf["UTA"],label="UTA")
plt.legend(loc=0)
plt.show()<jupyter_output><empty_output><jupyter_text>Estimate Hurst exponents for each team.<jupyter_code>plt.figure(figsize=(10,8))
fits=[]
# by setting qs you also set the range in which H will be estimated
qs=np.unique(np.logspace(0.7,1.8,num=150).astype(int))
# for each team
for team in df.columns:
    # obtain F_q(s) with q=2 (corresponds to the original DFA procedure)
    fqs=dfa(list(profileDf[team].values),2,qs)
    plt.plot(np.log10(qs),np.log10(fqs),label=team)
    # fit lg(F(s)) linearly
    params,cov=spo.curve_fit(lambda x,a,b: a*x+b,np.log10(qs),np.log10(fqs))
    # we use correlation coefficient for the goodness of fit
    # we have selected qs bounds to obtain the largest minimum
    # correlation coefficient in the data set
    corr=np.corrcoef(np.log10(fqs),params[0]*np.log10(qs)+params[1])[0,1]
    fits+=[[team,params[0],cov[0][0]**0.5,corr],]
plt.legend(loc=0)
plt.show()

dfaDf=pd.DataFrame(fits,columns=["team","H","err","corr"])
dfaDf
dfaDf.to_csv(outputFile,float_format="%.5f")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16021011162179907, 'fraction_numerical': 0.023637557452396585, 'mean_word_length': 6.696969696969697, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '524241', 'license': 'Unlicense', 'n_tokens_mistral': 621, 'n_tokens_neox': 589, 'n_words': 113, 'path': 'data-analyze-original.ipynb', 'repo_name': 'akononovicius/illussion-of-persistence-nba-2018', 'size': '1523'}