Created
August 6, 2021 04:08
-
-
Save mtmoses/035df8973a3b353cff424f6bfc423ece to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def partition_function(SIGMA, DELTA, XT, Q): | |
print("Calculating the partition function...\nThis step will take quite a while... so strap yourself in...\n") | |
SIGMA=[[0 for x in range(len(DELTA))] for y in range(len(Q))] | |
for k in range (0, len(Q)): | |
if k%30==0: | |
print("calculating i=" + str(k) + ' out of ' + str(len(Q)-1)) | |
for j in range (0,len(DELTA)): | |
for i in range (0,len(XT)-1): | |
if i < int(len(XT)/DELTA[j]): | |
SIGMA[k][j]=SIGMA[k][j] + abs(XT[i*DELTA[j]+DELTA[j]]-XT[i*DELTA[j]])**Q[k] | |
SIGMA=pd.DataFrame(SIGMA) | |
for i in range (0,len(Q)): | |
SIGMA.rename(index={SIGMA.index[i]:Q[i]}, inplace=True) | |
for i in range (len(DELTA)-1,-1,-1): | |
SIGMA.rename(columns={SIGMA.columns[i]:DELTA[i]}, inplace=True) | |
print("Done! Your partition function is ready!\n") | |
return SIGMA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment