Re: Calculating cumulative probability
- From: NZTideMan <mulgor@xxxxxxxxx>
- Date: Thu, 14 Feb 2008 14:50:14 -0800 (PST)
On Feb 15, 10:53 am, "Roger Stafford"
<ellieandrogerxy...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
"Roger Stafford" <ellieandrogerxy...@xxxxxxxxxxxxxxxxxxxxxx> wrote in
message <fp24vh$49...@xxxxxxxxxxxxxxxxxx>...
Since you know X and Y to be independent random variables, your desired
probability can be expressed as the iterated integral:
P(k) = integral, 0 to inf, (integral, y to y+k, f(x)*g(y) dx) dy
where f(x) and g(y) are the respective probability density functions of X andY.
That is: the integral from 0 to infinity of the integral from y to y+k of theevaluate
product f(x)*g(y), first with respect to x and then with respect to y. (I would
not have used the term "cumulative probability" to describe this particular
probability, however.) Unfortunately, matlab's 'dblquad' is unable to
a double integral in this form where the inner limits of integration dependon
the outer variable.
I can see two possibilities for numerically calculating this using matlab.(x),
First, if you already know the cumulative distribution of X as a function, F
the above can then be directly expressed as the single integral:
integral, 0 to inf, (F(y+k)-F(y))*g(y) dy
by direct substitution of F(y+k)-F(y) for the inner integral after factoringout
the g(y). Any of the matlab single quadrature functions can be used forthis:
'quad', 'quad8', etc.
The other possibility is to make a change of variable. Define
u = x - y
Then the iterated integral can be converted to the form
integral, 0 to inf, integral, 0 to k, f(u+y)*g(y) du dy
(Note that the Jacobian in this case is just 1.) This is in a form that can be
used by 'dblquad' since the inner limits are independent of y values. This is
the method you should use if you know only the two probability density
functions.
Note that each of these forms requires a separate numerical integrationfor
each desired value of k. There is always the possibility that, depending on
the functions, f(x) and g(y), there may exist an analytic solution to these
integrals using the 'int' function of the Symbolic Toolbox, but the odds are
heavily against this I would think.
Roger Stafford
-------
I should have warned you that matlab's numerical quadrature functions
cannot actually accept infinite limits. in your problem you will have to use a
finite limit that is sufficiently large to encompass all the areas with significant
probability densities, but not so large as to confuse the routine into taking
too few samples of the integrands in the critical areas to attain the needed
accuracy. These routines don't seem to be particularly robust in this regard.
You'll have to experiment with them a bit.
Roger Stafford- Hide quoted text -
- Show quoted text -
Another way is to hit it with the sledge hammer: Monte Carlo
simulation.
Sample, say, a million from each distribution, then do a 2-D histogram
on the results.
Repeat this many times and use allstats (from the File Exchange) to
calculate the statistics for each bin in the histogram.
When the standard errors for each bin in the histogram reduce to an
acceptable level, you're done.
.
- Follow-Ups:
- Re: Calculating cumulative probability
- From: Roger Stafford
- Re: Calculating cumulative probability
- References:
- Calculating cumulative probability
- From: Omkar Palsule-Desai
- Re: Calculating cumulative probability
- From: Roger Stafford
- Re: Calculating cumulative probability
- From: Roger Stafford
- Calculating cumulative probability
- Prev by Date: Re: fprintf: space in text
- Next by Date: Re: fprintf: space in text
- Previous by thread: Re: Calculating cumulative probability
- Next by thread: Re: Calculating cumulative probability
- Index(es):
Relevant Pages
|