HMWK 11 :Wiener process simulation (ABM, Brownian motion)
Intro
HMWK 11 :Wiener process simulation (ABM, Brownian motion)
Intro
In Homework 7, I modeled server security as a “biased random walk.” It was a straightforward concept: every week, the system either scored a +1 (a secure week) or a -1 (a breach), depending on the probability of an attack succeeding.
In Homework 11 ,the goal is to take that concept of “random evolution over time” and give it a major upgrade. We are moving from simple discrete steps to real stochastic calculus, simulating a Wiener process (Brownian motion) and solving Stochastic Differential Equations (SDEs) using the Euler–Maruyama method.
To visualize this, I built an interactive simulator that runs entirely in your browser.
👉 Try the live simulator here:https://abhishekreddy23.github.io/HW-11/
From Homework 7 to Homework 11
In Homework 7, the logic was discrete:
- Time was measured in weeks (1, 2, …).
- Position was a score, S_n.
- Movement was a simple step: +1 if the server survived, -1 if it was breached.
Mathematically, this was a biased random walk. We saw that after n weeks, the total score followed a binomial distribution. If you ran it long enough, the Central Limit Theorem kicked in, and it started to look like a bell curve (Normal distribution).
Homework 11 is essentially the continuous-time cousin of that model:
- Instead of discrete jumps of pm 1, the process evolves in continuous time.
- It uses Gaussian increments.
This is the definition of a Wiener process, or standard Brownian motion.
1. The Wiener Process and Arithmetic Brownian Motion
The core SDE driving this assignment is:

SDE
Where:
- u is the drift (the average trend).
- σ is the volatility (the randomness).
- W_t is the standard Wiener process (Brownian motion).
If we simplify this by setting the trend u = 0, the volatility σ=1, and start at X_0 = 0, we get a standard Wiener process. Theoretically, the final value at time T follows a normal distribution:
X_T ~=N(0, T)
In the simulator, you can replicate this by selecting Model = ABM (Arithmetic Brownian Motion) with default settings.
More generally, for ABM, the math tells us exactly where we should end up:
X_T =N(X_0 + u T,σ² T)
This closed-form formula gives us a “ground truth” to validate our simulation against.
2. Optional Generalization: Geometric Brownian Motion
The homework included an optional challenge to handle more general SDEs. I decided to implement Geometric Brownian Motion (GBM), which is the standard model used in mathematical finance.
The SDE for GBM looks like this:
*dS_t =u S_tdt + σS_tdW_t**
Here, both the drift and diffusion depend on the current state (S_t). This ensures the value never drops below zero and produces a log-normal distribution.
For GBM, we have an exact discretization formula:

My simulator supports both:
- ABM via the Euler–Maruyama approximation.
- GBM via this exact closed-form step.
This demonstrates how the same code structure can handle different SDEs just by swapping the logic.
3. Euler–Maruyama: From Math to Code
How do we actually code an SDE? We use the Euler–Maruyama method, which is the SDE analogue of the standard Euler method for ODEs.
We chop time into small steps . The update rule is:

Here, the random jump isΔ W_i = sqrt{Δt}\,Z_i,
where Z_i ~{N}(0,1)$.
For Arithmetic Brownian Motion (ABM), the update rule simplifies to:

This is exactly what the simulator calculates at every step when the ABM model is selected.
4. Generating Gaussian Noise with Box–Muller
The professor explicitly requested that we use the Box–Muller method for the random “jumps” rather than a built-in library generator.
The simulator implements this directly. It takes two independent uniform random variables (U_1, U_2) and transforms them into a standard normal (Z)

Every time the simulation needs a random increment Z_i, it calls this custom function.
5. Convergence and Validation
To prove the simulation works, the app runs many independent paths (e.g., 2000) and performs a check:
- It plots sample trajectories.
- It computes the empirical mean and variance of the terminal values.
- It compares them against the theoretical formulas.
For ABM, we expect:

The UI includes a “Convergence” table showing the theoretical vs. empirical values (and the relative error). This allows you to see the Law of Large Numbers in action as the number of paths grows.
6. Playing With the Simulator
You can experiment with the simulator here: https://abhishekreddy23.github.io/HW-11/
Things to try:
- Standard Wiener Process: Set Model to ABM, X_0=0, u=0,σ=0 . Increase time T and watch the variance grow linearly.
- Drifted Brownian Motion: Use u > 0 and see how the average line drifts upward while the paths fluctuate around it.
- Geometric Brownian Motion: Switch to GBM, set S_0=100. Observe that paths stay positive and behave like financial price trajectories.
7. Conclusion
Homework 7 started with a discrete, biased random walk for cybersecurity. Homework 11 lifts that idea into the world of SDEs:
- Time becomes continuous.
- Steps become Gaussian.
- The evolution is described by an SDE.
- The simulator is built via Euler–Maruyama (ABM) and an exact scheme (GBM).
- Gaussian noise is generated explicitly via Box–Muller.
The result is both a learning tool and a playground: you can visualize Brownian motion, test convergence, and see how different SDEs behave, all from a single interactive web page.
👉 Play with the live implementation here: https://abhishekreddy23.github.io/HW-11/
메타데이터
- post_id
- 37bc0d91bc95
- slug
- hmwk-11-wiener-process-simulation-abm-brownian-motion-37bc0d91bc95
- url
- https://medium.com/@gadeabhishekreddy/hmwk-11-wiener-process-simulation-abm-brownian-motion-37bc0d91bc95
- canonical_url
- https://medium.com/@gadeabhishekreddy/hmwk-11-wiener-process-simulation-abm-brownian-motion-37bc0d91bc95
- author_url
- https://medium.com/@gadeabhishekreddy
- status
- ok
- fetched_at
- 2026-07-29 18:51:22