How do I use Brownian motion code?
6 views (last 30 days)
Show older comments
I know brownian motion code is bm(mu sigma)
I can get mu(mean), sigma(variance)from the data set.
I need a graph and other information about brownian motion from this code.(such as dW(t).
x(t) = x_0 + (mu(t)) + (sigma(t)*dW(t))
I looked at the mathwork website about brownian motion but all I get is
obj =
Class BM: Brownian Motion
----------------------------------------
Dimensions: State = 1, Brownian = 1
----------------------------------------
StartTime: 0
StartState: 0
Correlation: 1
Drift: drift rate function F(t,X(t))
Diffusion: diffusion rate function G(t,X(t))
Simulation: simulation method/function simByEuler
Mu: 45.5
Sigma: 24.8267
I need an actual number with equation. And a motion graph.
How do I get that?
Please explain step by step.
Thank you.
0 Comments
Answers (1)
Hari
on 11 Jun 2025
Hi,
I understand that you want to simulate and visualize Brownian motion using your own values of mu (mean drift) and sigma (volatility), and you’d like to see both the motion graph and the increment values (dW).
I assume you already have numerical values for mu and sigma based on your data, and you're looking for a step-by-step way to simulate and plot the Brownian motion in MATLAB, along with calculating the stochastic increments.
In order to simulate Brownian motion and analyze it, you can follow the below steps:
Step 1: Set up the time parameters
Define how long the simulation will run and how many points you want. This means setting a time range (T) and number of steps (N).
The time step (dt) is then calculated as T divided by N.
Step 2: Generate the Brownian increments (dW)
Create a vector of random values from a normal distribution with mean 0 and standard deviation sqrt(dt).
This models the random changes in the Brownian process at each time step.
Step 3: Simulate Brownian motion (W)
Calculate W by taking the cumulative sum of dW.
To apply drift and volatility, compute x as:
x = x0 + mu * t + sigma * W
where t is the vector of time values and x0 is the starting point (often 0).
Step 4: Plot the Brownian motion path
Plot x against time to visualize the Brownian motion with drift and diffusion.
Step 5: Output or analyze dW if needed
If you want to understand the stochastic component, plot dW separately or save it for analysis.
Refer to the documentation of "randn" function to generate normal random values:
Refer to the documentation of "cumsum" function for cumulative sum:
Refer to the documentation of "plot" function for plotting:
Hope this helps!
0 Comments
See Also
Categories
Find more on Chassis Systems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!