<jupyter_start><jupyter_text>Let $N(\mu,\sigma^2)$ be a normal distribution. A Wiener process $W(t)$ is the limit of a discrete stocastic process. To construct this process, split the total time $t$ into $n$ small intervals of length $h$: $t=nh$. Then, at each time $t_j=jh$, the change in $W$ will just be normally distributed:$$W_{j+1}-W_j = \sqrt{h}Z_j$$where $Z_j \sim N(0,1)$. Finally take $h\rightarrow0$ to make it a continuous process. Here is a Python function that implements one realization of a Wiener process:<jupyter_code>def wiener(n, dt, t_init=0, w_init=0.0):
    """Returns one realization of a Wiener process with n steps of length dt.
    The time and Wiener series can be initialized using t_init and w_init respectively."""
    n+=1
    t_series = np.arange(t_init,n*dt,dt)
    h = t_series[1]-t_series[0]
    z = np.random.normal(0.0,1.0,n)
    dw = np.sqrt(h)*z
    dw[0] = w_init
    w_series = dw.cumsum()
    return t_series, w_series
t, W = wiener(500,1)
plt.plot(t,W)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1276803118908382, 'fraction_numerical': 0.01949317738791423, 'mean_word_length': 4.239795918367347, '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': '551746', 'license': 'MIT', 'n_tokens_mistral': 380, 'n_tokens_neox': 372, 'n_words': 125, 'path': 'wiener_process.ipynb', 'repo_name': 'rmorshea/quantfi', 'size': '1026'}