Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to make a 3D plot of two variable i1 and b1. The dependent variable results from a pay-off function

payoff1 :=  q1*((1 + g1)*b1*10000 - i1*10000) - (1 - q1)*(1 - d)*i1*10000

The problem is that q1 is actually the result from an integral calculation:

q1 := NIntegrate[combo1, {x, 0, 2000000}]

where "combo1" is a function that is defined higher and that is also dependent on i1 and b1.

I want to make this plot:

Plot3D[payoff1, {i1, 0, 20}, {b1, 0, 50}]

So for every value of i1 and b1, it should make the q1-calculation, but what Mathematica does (because I think I have a bug in my code here) is to always take the initial q1 value.

How could I solve this problem?

Thank you!

The entire code can be found here: First some parameters are introduced:

mue = 0.25
mui = 0.25
lambdae = 0.25
lambdai = 0.25
sigmap = 0.05
betae = 0.05
betai = 0.05
gammae = 0.10
gammai = 0.50
d = 0.8
experience1 = 7
experience2 = 6

Some functions are added:

g1 := betae*Exp[-mue*experience1] + betai*Exp[-mui*i1]
g2 := betae*Exp[-mue*experience2] + betai*Exp[-mui*i2]
sd1 := Sqrt[sigmap^2 + (gammae*Exp[-lambdae*experience1])^2 + (gammai*
   Exp[-lambdai*i1])^2]*1000000
sd2 := Sqrt[sigmap^2 + (gammae*Exp[-lambdae*experience2])^2 + (gammai*
   Exp[-lambdai*i2])^2]*1000000

bid1 := NormalDistribution[1000000*(1 + g1)*(1 + b1/100), sd1]
bid2 := NormalDistribution[1000000*(1 + b2/100) (1 + g2), sd2]

pbid1 := PDF[bid1, x]
pbid2 := PDF[bid2, x]
cbid1 := 1 - CDF[bid1, x]
cbid2 := 1 - CDF[bid2, x]
combo1 := pbid1*cbid2

q1 := NIntegrate[combo1, {x, 0, 2000000}]

combo2 := pbid2*cbid1

q2 := NIntegrate[combo2, {x, 0, 2000000}]


payoff1 := q1*((1 + g1)*b1*10000 - i1*10000) - (1 - q1)*(1 - d)*i1*10000
payoff2 := q2*((1 + g2)*b2*10000 - i2*10000) - (1 - q2)*(1 - d)*i2*10000

And now I want to make the plot for payoff1, given that (example):

i2 = 5
b2 = 10

Plot3D[payoff1, {i1, 0, 20}, {b1, 0, 50}]

If I make a plot for q1, I think I get the right one, but the one of the pay-off does not seem correct/logic.

Afterwards I will need to solve the system of equations (given that now i1,i2,b1 and b2 are unknown) There is also still a problem, but that might be caused by the above stated problem.

eq1 := D[payoff1, i1]
eq2 := D[payoff1, b1]
eq3 := D[payoff2, i2]
eq4 := D[payoff2, b2]

FindRoot[{eq1 == 0, eq2 == 0, eq3 == 0, eq4 == 0}  , {{i1, 5}, {i2, 5}, {b1, 5}, {b2, 5}}]

I am very new to the world of Mathematica, so thank you for any help.

Regards,

Dennis

New code:

I implemented the new code now, but than a numerical integration error occurs and there is already a problem by making pbid1 (a normal probability distribution function).

Here is the new code (so, i2 and b2 are given; i1 and b1 are unknown):

The parameters that were introduced are still te same. The functions become:

g1[i1_] := betae*Exp[-mue*experience1] + betai*Exp[-mui*i1]
g2 := betae*Exp[-mue*experience2] + betai*Exp[-mui*i2]

sd1[i1_] := Sqrt[sigmap^2 + (gammae*Exp[-lambdae*experience1])^2 + (gammai*Exp[-lambdai*i1])^2]*1000000
sd2 := Sqrt[sigmap^2 + (gammae*Exp[-lambdae*experience2])^2 + (gammai*Exp[-lambdai*i2])^2]*1000000

bid1[b1_, g1_, sd1_] := NormalDistribution[1000000*(1 + g1[i1])*(1 + b1/100), sd1[i1]]
bid2 := NormalDistribution[1000000*(1 + b2/100) (1 + g2), sd2]

A problem occurs already in this statement:

pbid1[bid1_, x_] := PDF[bid1[b1, g1[i1], sd1[i1]], x]

The probability density function pbid2 causes no problems:

pbid2[x_] := PDF[bid2, x]

The remainder of the code:

cbid1[bid1_, x_] := 1 - CDF[bid1[b1, g1[i1], sd1[i1]], x]
cbid2[x_] := 1 - CDF[bid2, x]

combo1[pbid1_, cbid2_] := pbid1[bid1[b1, g1[i1], sd1[i1]], x]*cbid2[x]

q1[combo1_] := NIntegrate[combo1[pbid1[bid1[b1, g1[i1], sd1[i1]], x], cbid2[x]], {x, 0, 2000000}]

When Evaluating the integral, I get the non-numerical values error.

And finally, for the pay-off, I was thinking of this formula:

payoff1[combo1_, g1_, b1_, i1_] := q1[combo1[pbid1[bid1[b1, g1[i1], sd1[i1]], x], cbid2[x]]]*((1 + g1[i1])*b1*10000 - i1*10000) - (1 - q1[combo1[pbid1[bid1[b1, g1[i1], sd1[i1]], x], cbid2[x]]])*(1 - d)*i1*10000

I have not really a clue where something is going wrong.

share|improve this question
    
Hi. It would be easier to give a solution if you included all of your code. Could you do that please? –  WalkingRandomly Aug 1 '13 at 12:59
    
Also, please note that code can and preferably should be formatted. I've done that for you, but try to do it yourself next time. See the help at the top of this page or the ? Button at the top right of the edit box. –  Sjoerd C. de Vries Aug 1 '13 at 13:25

2 Answers 2

up vote 1 down vote accepted

If you make the dependencies explicit you won't have these kinds of problems. Try something like this:

payoff1[b1_,q1_,g1_,i1_,d_] :=  q1*((1 + g1)*b1*10000 - i1*10000) - (1 - q1)*(1 - d)*i1*10000

q1[i1_,b1_] := NIntegrate[combo1[i1,b1,x], {x, 0, 2000000}]

Plot3D[payoff1[b1,q1[i1,b1],g1,i1,d], {i1, 0, 20}, {b1, 0, 50}]
share|improve this answer
    
Thank you. I have added the entire code now. I will try to adopt your solution proposal to the full example. –  Dennis De Clerck Aug 2 '13 at 7:52
    
I have also added the new code, but unfortunately some things are going wrong when executing the statements. I was wondering whether you already see whether it is a problem in my logic? I really appreciate the feedback. Kind regards –  Dennis De Clerck Aug 2 '13 at 9:55
    
@DennisDeClerck unfortunately I can't check anything at the moment and for some days to go as my only access to something resembling a PC are my iPad and iPhone. –  Sjoerd C. de Vries Aug 2 '13 at 10:46
    
@DennisDeClerck But from glancing at your code you seem to confuse symbols bound to a function definition with function names already defined. –  Sjoerd C. de Vries Aug 2 '13 at 10:51
    
I'm not completely sure whether I understand this. But it can wait of course (it is weekend anyway). Thanks already for the help. –  Dennis De Clerck Aug 2 '13 at 12:17

You should make your functions actual mathematica functions:

payoff1[q1_, g1_, b1_, i1_] :=  q1*((1 + g1)*b1*10000 - i1*10000) - (1 - q1)*(1 - d)*i1*10000

and similar for q1 and whatever is inside of combo1. Then, you can do

Plot3D[payoff1[q1[(* whatever *)], g1, b1, i1]], {i1, 0, 20}, {b1, 0, 50}]
share|improve this answer
    
I enterered the entire code now plus the things I've changed, but now I encounter problems with evaluating the integrals... Thank you very much for the feedback. –  Dennis De Clerck Aug 2 '13 at 9:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.