Up Panel: Multiple simulated paths of the process which is stopped upon hitting . This shows gambler's ruin behavior, and is not a martingale.
Down Panel: Paths of with an additional stopping criterion: the process is also stopped when it reaches a magnitude of . This no longer suffers from gambler's ruin behavior, and is a martingale.
```python
import numpy as np
import matplotlib.pyplot as plt
dw = 0.05
dt = dw**2
num_samples = 5
def generate_Xt(k=None):
W = np.array([])
while True:
B = np.array([np.random.default_rng().choice([-1, 1]) for _ in range(1000)])
W = np.append(W, np.cumsum(B) * dw)
t = np.arange(len(W)) * dt
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.