Plotting the Gaussian probability distribution for a Brownian process over time
Show older comments
I am trying to plot the change in a Gaussian probability distribution over time, where the variance is 2Dt (as is the case for Brownian motion). I wish to plot the Gaussian probability disitrbution over the positions x, with a seperate plot for different observation times. This is my code:
time = [0.5, 1.0, 3.0, 5.0, 10.0];
figure();
for i = time
x = -20:0.01:20;
y = exp(-((x).^2)./2*i)*(1./sqrt(2*pi*i));
plot(x,y,'DisplayName',num2str(i));
hold on
end
legend
This is the final plot:

However, this is not how I expect this process to look. The curve should actually start as a relatively sharp peak and then flatten out over time, modelling the process of a freely diffusing particle. I am not sure what I am doing wrong here, as plotting the same expression in Desmos and parametrising time gives me the result I am looking for. An example for the kind of curves I should get:

I also tried plotting it using fplot, and defining x as a symbol. I got the same results.
Any help would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Annotations 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!