Integration in Matlab for calculating if two distributions are significantly different

7 views (last 30 days)
Dear community,
i am starting to use matlab for integration. More specifically, i have to find the likelihood that a Probability distribution A is greater than a probability distribution B (i.e. P(A - B>0). (I can not use ttests and the like for specific reasons, so i have to resort on probability principles).
Both distributions A and B resemble normal distributions (albeit not perfect in some cases). i basically need to solve the following (sorry for the notation)
p = INTEGRAL [-Inf,+Inf] of g(B) * INTEGRAL [min real value of B, +Inf] f(A) in db da.
i have tried the following code, but i am not sure that it does what i actually want him to do:
fun2 = @(y) normpdf(y,m_a(i), sd_a(i)); fun3 = @(x,y) (normpdf(x,m_b(i),sd_b(i)))*(integral(fun2, min_b(i), Inf(i)))
q(i) = integral (fun3, -Inf,Inf)
i have done the same by explicitly writing the equation for the normal distribution down and have the same results.
Any help would be greatly appreciated.
jacopo

Accepted Answer

Roger Stafford
Roger Stafford on 12 Sep 2013
Edited: Roger Stafford on 12 Sep 2013
First, it should be noted that you are making the fundamental assumption that your two probability distributions are independent. Otherwise it would be incorrect to just multiply their densities.
Given that they are independent, the matlab function 'integral2' is designed to handle just this kind of problem with f(a) and g(b) being the respective densities.
fun = @(a,b) f(a)*g(b)
bmin = @(a) a
p = integral2(fun,-inf,+inf,bmin,+inf);
(Corrected)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!