1
$\begingroup$

I am new to Mathematica, and don't understand what is wrong with this command. In any of these inputs, the output is just a copy of what I wrote as an input. Thanks a lot for your help.

F[h_, x_] := CDF[NormalDistribution[h, σ], x] 
Obj[k, q, p] := F[k - q, q - p] (p - q^2/2) 
Maximize[Obj[k, q, p] , q] 
Maximize[1/2 (p - q^2/2) Erfc[(k + p - 2 q)/(Sqrt[2] σ)], q] 
Maximize[ 1/2 (p - q^2/2) Erfc[(k + p - 2 q)/(Sqrt[2] σ)], q, {p > 0, q > 0}] 

(* Out: Maximize[ 1/2 (p - q^2/2) Erfc[(k + p - 2 q)/(Sqrt[2] σ)], q, {p > 0, q > 0}] *)

Obj[k, q, p] 
(* Out: 1/2 (p - q^2/2) Erfc[(k + p - 2 q)/(Sqrt[2] σ)] *)
$\endgroup$
2
  • $\begingroup$ Lisa, thank you for adding the code. I formatted it and added it to your question. You can always edit your question yourself using the "edit" link right below it. $\endgroup$
    – MarcoB
    Jun 11, 2018 at 16:13
  • $\begingroup$ Thanks a lot! @MarcoB $\endgroup$
    – LisaB
    Jun 12, 2018 at 15:17

1 Answer 1

3
$\begingroup$

There may be nor general analytic solution. You only get results, if you feed in numerical values for p,k,sigma.

F[h_, x_, \[Sigma]_] = CDF[NormalDistribution[h, \[Sigma]], x]

Obj[k_, q_, p_, \[Sigma]_] = F[k - q, q - p, \[Sigma]] (p - q^2/2)

max[p_, k_, \[Sigma]_] := 
   Maximize[{Obj[k, q, p, \[Sigma]], 0 < q < 10}, q]

Even simple Maximize yields complicated root-objects.

max[1, 1, 1]

(*   {-(1/4) Erfc[(1/Sqrt[
      2])(2 - 2 Root[{-2 Sqrt[2/\[Pi]] + 
      E^(2 (-1 + #1)^2) Erfc[(2 - 2 #1)/Sqrt[2]] #1 + 
      Sqrt[2/\[Pi]] #1^2 &, 0.94919764352934575212}])] (-2 + 
   Root[{-2 Sqrt[2/\[Pi]] + 
    E^(2 (-1 + #1)^2) Erfc[(2 - 2 #1)/Sqrt[2]] #1 + 
    Sqrt[2/\[Pi]] #1^2 &, 0.94919764352934575212}]^2), {q -> 
   Root[{-2 Sqrt[2/\[Pi]] + 
   E^(2 (-1 + #1)^2) Erfc[(2 - 2 #1)/Sqrt[2]] #1 + 
   Sqrt[2/\[Pi]] #1^2 &, 0.94919764352934575212}]}}   *)

Numerical maximisation is faster

nmax[p_, k_, \[Sigma]_] := NMaximize[Obj[k, q, p, \[Sigma]], q]

Plot3D[First@nmax[p, k, 1], {p, 0, 1}, {k, 0, 1}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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