<jupyter_start><jupyter_text>Explore Brownian MotionWe want to model a random walker in 2D as a proxy for a diffusing molecule.We need to think about the following aspects:* define a start position* for each step, draw two random numbers to mimic a random step in 2D* update the position* create a list with all positions and plot the results  First, let's gather all the tools<jupyter_code># load extra functionality for numerics & mathematics (numpy), and for plotting
import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Random number generation with `Python`Creating truely **random numbers** with a computer is much more complicated than it sounds. However, here, in our introductory course, we don't need to worry too much about all the intricacies. Let's just use Python's build in random number generator, which are sufficient for our illustrative purposes.Random numbers can be *drawn* from various distributions using the `np.random` modul. Exploring this modul and all the functions available in it will give you a good overview of what is possible with almost no effort on our side.<jupyter_code># explore the np.random module
?np.random
# draw one random integer between **low**and **high**
np.random.randint(3, 27)
start = [0, 0]
start[0]
# random number between 0 and 1
np.random.rand()
np.random.normal()
def make_step(current_position):
    ### make a random step
    # Input: current position should be a list with 2 elements, x and y positions
    # first elemet is accessed with [0] and refers to x position
    # second element [1] refers to y position
    
    ### 

    x = np.random.normal()
    y = np.random.normal()

    new_position = [current_position[0] + x, current_position[1] + y]

    return new_position
make_step(start)
#random_walker = [position, step]

position = []
position.append(start)

for i in range(10000):
    position.append(make_step(position[i]))
position
plt.plot(position)
# plot as 2D
plt.plot(position[0], position[1])
position[0:4][1]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0811073336571151, 'fraction_numerical': 0.012627489072365225, 'mean_word_length': 4.786516853932584, 'pattern_counts': {'":': 0, '<': 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': '36538', 'license': 'Apache-2.0', 'n_tokens_mistral': 611, 'n_tokens_neox': 571, 'n_words': 262, 'path': 'code/Explore_Brownian_Motion.ipynb', 'repo_name': 'majahn/intro_data_analysis_biophys_101', 'size': '2059'}