clc; close all; clear all; %-------------------------------------- %Monte Carlo Integration %-------------------------------------- %-------------------------------------- %limits LowerLimit=1; UpperLimit=3; %-------------------------------------- %generate uniformly distributed random %numbers within the range n=10000; x=LowerLimit+(UpperLimit-LowerLimit)*rand(n,1); %-------------------------------------- %Probability distribution function for %uniformly distributed random numbers q=1/(UpperLimit-LowerLimit); %-------------------------------------- %function to integrate f=3.*x.*x; i=mean(f./q) %--------------------------------------
Friday, June 3, 2011
Monte Carlo integration
As I am reading about Particle Filter, just for fun, I wrote a Matlab program that performs Monte Carlo integration using uniform distribution. The equation and the program are as follows.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Comments are moderated and don't be surprised if your comment does not appear promptly.