MATLAB: How to calculate integral pdf

integral

Hi,
I have pdf (probability density function) of my outputs but i dont know how to determine the probability that x1<x<x2 by calculating Integral(P(x)) between x1 and x2 on MATLAB…
ANY HELP? 😀

Best Answer

The probability is the integral of the PDF over a range. You can approximate that integral as a sum:
pdf = @(x) 2*x;
x1 = 0;
x2 = 1;
dx = 0.0001;
xrange = x1 : dx : (x2-dx);
probability = sum(pdf(xrange)*dx)
Note that I have done the approximation very crudely, just to keep things simple. Better approximations are possible.