2
$\begingroup$

I plotted a pretty complex region in the xy plane (code given below). Basically, one of the inequalities is really complex and needs to be numerically approximated. In my code I do this with FindRoot. The problem is, when I then try to calculate the area of that region, the Area function doesn't work. Is there a special way to do this?

g1[p_] := PDF[NormalDistribution[5, 1], p];
G1 = CDF[NormalDistribution[5, 1]];
ClearAll[h];
h[alpha_, beta_, s2_, guess_ : 0] := FindRoot[
  s2 - p + beta (p - 5 alpha) == G1[p - 5 alpha]/g1[p - 5 alpha], {p, 
   guess}]
ClearAll[f];
f[alpha_, beta_, s2_, guess_ : 0] := Block[{p}, p /. First[h[alpha, beta, s2, guess]]];
Test[a_,b_,y_,s2_] := If[y >= s2,
     f[a, b, y] - a (f[a, b, y] - b (f[a, b, y] - 5 a) +
         (G1[f[a, b, y] - 5 a])/(g1[f[a, b, y] - 5 a])),
     f[a, b, y] - a (5 - (g1[s2]/G1[s2]))]
SignalStar[alpha_, beta_, p_, guess_ : 0] := FindRoot[
  s2 - p + beta (p - 5 alpha) == G1[p - 5 alpha]/g1[p - 5 alpha], {s2, 
   guess}]
FindSignalStar[alpha_, beta_, p_, guess_ : 0] := Block[{s2}, s2 /. First[SignalStar[alpha, beta, p, guess]]];
Manipulate[RegionPlot[{   y >= x (1 - b)/(1 - a),   x <=Test[a,b,y,FindSignalStar[a,b,5]]},
  {x, 0, 10}, {y, 0, 10}, PlotPoints -> 10],
 {a, -2, 2}, {b, -2, 2}]
Manipulate[Area[ x <=Test[a,b,y,FindSignalStar[a,b,5]],{x,0,10},{y,0,10}],{a,-2,2,0.1},{b,-2,2,0.1}]
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.