Derivative of integral over distribution

Hi,

I am doing work that requires me to take the derivative of an integral over a distribution. I believe I calculated it correctly, but when I simulate the results in matlab, the plot for the integral and its derivative don't match up.

Here is the equation:

$$\int_{-\infty }^{\infty }\left[ p[1-G(p-y)]+\int_{-\infty }^{p-y}zg(z)dz\right] f(y)dy$$

where G is the cdf of z with g the associated pdf, and F is the CDF of y with f the associated pdf.

I believe the derivative is the following:

$$\int_{-\infty }^{\infty }\left[ [1-G(p-y)]-yg(p-y)dz\right]$$

But, when I simulate the two in matlab the graphs don't match up. See attached pdf.

Any insight would be greatly appreciated.

All the best,
Bob

Attachments

• Sample.pdf
65.3 KB · Views: 160
Last edited:

Here is the equation:
$$\int_{-\infty }^{\infty }\left[ p[1-G(p-y)]+\int_{-\infty }^{p-y}zg(z)dz\right] f(y)dy$$
where G is the cdf of z with g the associated pdf, and F is the CDF of y with f the associated pdf.

I believe the derivative is the following:

$$\int_{-\infty }^{\infty }\left[ [1-G(p-y)]-yg(p-y)dz\right]$$

But, when I simulate the two in matlab the graphs don't match up. See attached pdf.

Stephen Tashi
I believe the derivative is the following:

$$\int_{-\infty }^{\infty }\left[ [1-G(p-y)]-yg(p-y)dz\right]$$

I don't understand what you did. Did you differentiate inside the integral sign with respect to $y$?

Did you differentiate $G(p-y)$ with respect to $y$? Why didn't it become $$g(p-y)$$ ?

Good point. My apologies. I need the derivative with respect to p. Thanks for responding!

Stephen Tashi
Assuming we can differentiate inside the integral sign, wouldn't we have:

$$D_p \left ( p(1 - G(p-y) \right) = 1 - G(p-y) - pg(p-y)$$

and
$$D_p \left(\int_{-\infty}^{p-y}zg(z) dz \right) = (p-y)g(p-y)$$

Yes, that's what I have thanks. Actually, I just noticed there is a type in the derivative that I wrote above. For some reason, the site's preview for latex doesn't work for me.

the derivative that I got, which confirms with yours, is:

$$\int_{-\infty }^{\infty }\left[ [1-G(p-y)]-pg(p-y)+\left( p-y\right) g(p-y)% \right] f(y)dy$$

and thus becomes:

$$\int_{-\infty }^{\infty }\left[ [1-G(p-y)]-yg(p-y)\right] f(y)dy$$

So, I wonder where I'm going wrong with my simulation. As indicated in my plots in sample.pdf above, the graphs of the two functions just don't match up. Given the functions, he graph of the first-order condition with respect to p should cross 0 where the graph of the first equation is at a maximum. Clearly from the graphs that I attached above, they don't. I'm perplexed. I'm pretty sure that I didn't make a coding mistake, but I guess if your calculation of the derivative agrees with mine, then I did somehow. Any suggestions a to how to determine which graph is correct, because I am using those functions in my simulation.

Stephen Tashi
For some reason, the site's preview for latex doesn't work for me.

It doesn't work for anybody. There's a bug in it. You have to do the preview and then have your browser reload the page. Before you reload it, the preview just looks crazy.

Stephen Tashi
Maybe regularity conditions for differentiating inside the integral don't apply. What are the specific functions involved?

In your first plot, why isn't the vertical axis in units of probability?

I'm just using the normal distribution.

So, y~N(1,1)
and z~N(0,1)

In other words, G = N(0,1) and F=N(1,1).

I haven't checked the regularity conditions. I guess I should.

I'm not sure what you mean by units of probability.
For the first graph, I fix a value for p, and then just take the expectation over y, using numerical quadrature. So, what I plot as "v" is just the value of that first equation for a given p. I do the same for the second graph, where "fonc" is the value of that second equation.

My end goal is to confirm the choice of maximum of the first function by finding the root (choice of p) of the first-order condition.