<jupyter_start><jupyter_text>Silly Wiki Walk<jupyter_code># pip3 install wikipedia-api
# pip install wikipedia<jupyter_output><empty_output><jupyter_text>Import libraries<jupyter_code>import wikipedia
import random<jupyter_output><empty_output><jupyter_text>Set initial page<jupyter_code>starting_page = "random walk"
target_page = starting_page # if recurrent
num_sims = 5
escape = 10
verbose = 1<jupyter_output><empty_output><jupyter_text>Execute<jupyter_code>counts = list()
non_recurrent = list()

for j in range(num_sims):
    
    if verbose == 1:
        print('Simulation ' + str(j) + ' ('+str(len(counts))+ ' hit target)')
        
    triggered = False
    num_steps = 0
    current_page = starting_page
    while triggered == False:
        num_steps  = num_steps + 1
        
        if verbose == 1:
            print('Step ' + str(num_steps) + ': ' + current_page)
                     
        the_page = wikipedia.page(current_page)
        current_page = the_page.links[random.randint(0,len(the_page.links))]
        
        if current_page == target_page:
            counts.append(j)
            triggered = True
        
        if num_steps == escape:
            non_recurrent.append(current_page)
            triggered = True<jupyter_output>Simulation 0 (0 hit target)
Step 1: random walk
Step 2: Unit root
Step 3: Statistical inference
Step 4: Bayes estimator
Step 5: Lp space
Step 6: <NAME>
Step 7: <NAME>
Step 8: International Standard Book Number
Step 9: ISO 2146
Step 10: Multibus
Simulation 1 (0 hit target)
Step 1: random walk
Step 2: Feller process
Step 3: Martingale difference sequence
Step 4: Bessel process
Step 5: Burkholder–Davis–Gundy inequalities
Step 6: Local martingale
Step 7: Random walk
Step 8: Uniform integrability
Step 9: <NAME>
Step 10: Library of Congress Control Number
Simulation 2 (0 hit target)
Step 1: random walk
Step 2: Boolean network
Step 3: Cox process
Step 4: Fleming–Viot process
Step 5: SABR volatility model
Step 6: Exotic derivative
Step 7: Constant maturity swap
Step 8: Intermarket Spread
Step 9: Dividend swap
Step 10: Straddle
Simulation 3 (0 hit target)
Step 1: random walk
Step 2: Factorial
Step 3: Bohr–Mollerup theorem
Step 4: <NAME>
Step 5: <NAME>[...]
{'fraction_non_alphanumeric': 0.08490566037735849, 'fraction_numerical': 0.026954177897574125, 'mean_word_length': 3.6395833333333334, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '487056', 'license': 'MIT', 'n_tokens_mistral': 788, 'n_tokens_neox': 705, 'n_words': 235, 'path': 'Silly_wiki_walk.ipynb', 'repo_name': 'Mitchellpkt/wikipedia_random_walk', 'size': '2270'}