<jupyter_start><jupyter_text><jupyter_code>import pylab
from collections import Counter
import os
import math
from pylab import *
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
import random
from random import seed
d = 4 # dimensions
n = 100
runs = 10000
r_lis = []
numberofruns = []

for j in range(runs):
        N = 0
        current_location = [0,0,0,0]
        visited_locations = [[0,0,0,0]]
        previous_step = None

        for i in range(n):
            while True:
                step = random.randint(1,8)
                if step == 1 and previous_step != 2:
                    current_location[0] += 1
                    break
                elif step == 2 and previous_step != 1:
                    current_location[0] -= 1
                    break
                elif step == 3 and previous_step != 4:
                    current_location[1] += 1
                    break
                elif step == 4 and previous_step != 3:
                    current_location[1] -= 1
                    break
                elif step == 5 and previous_step!= 6:
                    current_location[2] += 1
                    break
                elif step == 6 and previous_step!= 5:
                    current_location[2] -= 1
                    break
                elif step == 7 and previous_step!=8:
                    current_location[3] += 1
                    break
                elif step == 8 and previous_step!=7:
                    current_location[3] -= 1
                    break

            visited = False
            for visited_location in visited_locations:
                if visited_location[0] == current_location[0] and visited_location[1] == current_location[1] and visited_location[2] == current_location[2] and visited_location[3] == current_location[3]:
                    visited = True
            if visited:
                break
            N +=1
            visited_locations.append([current_location[0], current_location[1], current_location[2], current_location[3]])
            previous_step = step

        numberofruns.append(N)

        r_sqr = (current_location[0]**2 + current_location[1]**2 + current_location[2]**2 + current_location[3]**2)
        r_lis.append(r_sqr)
meanN = np.mean(numberofruns)
visited_arr = np.array(visited_locations)
msd = np.mean(r_lis)
p = np.log(msd)/np.log(meanN)
#print(n)
print ("P is: " + str(p))

c = Counter(numberofruns)
w = c[n]/float(runs)
print("Kerims Rnumber " + str(numberofruns))
print("Kerims C " + str(c))
print("Kerims w " + str(w))
omg = w*((2*d)-1)**(n-2)
s = np.log(omg)/float(n-2)
print ("Ratio successful runs: " + str(w))
print ("Entropy is: " + str(s))
print (meanN)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10817655571635311, 'fraction_numerical': 0.028581765557163533, 'mean_word_length': 1.8623188405797102, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '220760', 'license': 'MIT', 'n_tokens_mistral': 892, 'n_tokens_neox': 816, 'n_words': 209, 'path': 'Untitled1.ipynb', 'repo_name': 'Zeeko1996/Uncategorized_Code', 'size': '2764'}