Integration of the expected value

1 view (last 30 days)
Yuriy
Yuriy on 2 Aug 2022
Edited: Yuriy on 8 Aug 2022
Dear community!
I have an interval and an expected price which is laying on this interval. b is a constant.
I want to find all possible values of expected profit function which is expressed as and plot it.
is a c.d.f. of uniformly distrtubited density function .
Integrating by parts the expected price can be re-written as: . So, I am trying to write the following code, which doesn't work:, please see below. Any help will be highly apprerciated!
b = 1;
p = (0:0.01:b);
p_e = (p:0.01:b);
pd1 = makedist('Uniform','lower',p,'upper',b);
G = @(p) p + p * cdf - int((cdf), p, p, b);
y=G(p);
plot(p,y)
xlim([0 1])
ylim([0 +inf])
leg = legend('Expected profit','AutoUpdate','off');
title(leg,'Expected profit')
xlabel('Price')
ylabel('Expected Profit')
% put the grid on top of the colored area
set(gca, 'Layer', 'top')
grid on

Accepted Answer

Torsten
Torsten on 2 Aug 2022
Edited: Torsten on 3 Aug 2022
b = 1;
N = 2000000;
for i = 1:N
p(i) = b*rand;
pe(i) = p(i) + (b-p(i))*rand;
p2(i) = p(i) + pe(i);
end
ecdf(pe)
mean(p)
ans = 0.5000
mean(pe)
ans = 0.7499
mean(p2)
ans = 1.2499
  6 Comments
Torsten
Torsten on 5 Aug 2022
Edited: Torsten on 5 Aug 2022
If pi = p+pe is the profit, you can plot a probability distribution (pdf) for pi. It would look like
b = 1;
N = 20000000;
for i = 1:N
p(i) = b*rand;
pe(i) = p(i) + (b-p(i))*rand;
p2(i) = p(i) + pe(i);
end
ksdensity(p2)
xlim([0,2])
Yuriy
Yuriy on 8 Aug 2022
Edited: Yuriy on 8 Aug 2022
Great, thanks! Not sure if this answers my question, but I mark it because looks like it is the closest. Thank you! I think I need to reformulate my question. I need to draw 2 random variables p1 and p2 such that p1 is not equal to p2. And then my expecteds profit will be (p1 + p2) or (p1 + b) depends on which is greater (dominating). I will try to plot it too right now, but any help will be much appreciated becasue I am new to this and my learning curve is not the greatest, unfortunately.

Sign in to comment.

More Answers (1)

William Rose
William Rose on 2 Aug 2022
I'm not sure I understand. Is a uniformly distributed random variable, or is the expected value of p, which is a uniformly distributed random variable? You wrote inside the integral in the first equation, but after that, the subscript e disappeared. If is the random variable inside the integral, then it should be the vrable of integration, so the integral should have been . If that is the case, then you have
where b and p are constants. Which is just what you expect for the mean value of a uniformly distributed random variable.
Perhaps you meant to write for the first equation. If so, there is a different problem, which is that p cannot be the lower limit of integration and the variable of integration at the same time.
  1 Comment
Yuriy
Yuriy on 2 Aug 2022
Edited: Yuriy on 2 Aug 2022
I apologize for my messy explanation. A variable in the first period denoted , and in the second is . Therefore, .
So, in the first period I randomly draw p from the distribution with the support , and then in the second period I anticapate price raise, which will be from the same distribution but with the support . Therefore, I am trying to plot expected profits curve.
I see what you mean, and it is what MatLab saying about this piece of code:
p_e = (p:0.01:b);
But the expected price will depend on how price p changes the interval over which I am trying to intergate.

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!