This is my first time posting a question in StackExchange. I have encountered a certain problem and I can't seem too find a solution. Just a word of caution, I am kind of an amateur when it comes to Mathematica and the Wolfram language.
What I would like to do is create a graph of a function y=f[x]
, to illustrate the difference between optimal ("pointy" edge) and robust ("blunt" edge) solutions.
In the same graph/plot, I would like to show the distribution of the X quantity, correctly placed on the x-axis (under the pointy and blunt edges), as well as the corresponding distributions (preferably Smooth Histograms) of each Y quantity, also correctly placed, but vertically on the y-axis this time.
I have accomplished the first part, but I can't seem to find a way to place the y distributions too.
One way I have thought of facing this problem is to create the two Y-distributions and place them as transposed images on the plots
plot.
However, my programming abilities limit my end result.
This (low quality) picture I created in Photoshop, illustrates what I would like to do.
Please help!!
Below is the code I am using.
PS: any other comment, hint or piece of advise is greatly appreciated.
PPS: I also can't get the monochromatic theme to work for the plots
plot
f[x_]=InterpolatingPolynomial[{ { 3.61 ,7.29}, { 5.27, 2.21}, { 6.00, 4.00}, { 6.48, 6.68}, { 8.20, 7.30}, { 9.37, 6.31}, {10.25, 4.92}, {11.26, 3.52}, {12.40, 3.48}, {13.44, 3.48}, {14.28, 3.76}, {15.39, 6.58}, {15.90, 8.62} },x]
FindMinimum[f[x],{x,5}]
Result of FindMinimum: {1.69509,{x->5.45853}}
, the value of which I use in mopt
, for the pointy edge. For the blunt edge, mrob=12.5
seemed like a good guess.
mopt = 5.45853;
sopt = 0.5;
mrob = 12.5;
srob = sopt;
grob[x_] = PDF[NormalDistribution[mrob,srob],x];
gopt[x_] = PDF[NormalDistribution[mopt,sopt],x];
plots=Show[ Plot[ f[x],
{x,0,20},
RegionFunction->Function[{x,y},3.95<x<15.5],
PlotLegends->{"F(x)"},
PlotStyle->{Thick, Blue}
],
Plot[ grob[x],
{x,0,20},
RegionFunction->Function[{x,y},-srob<(x-mrob)/3<srob],
Filling->Axis,
PlotLegends->{"Nrob"},
PlotStyle->{Red, Dashing[Tiny]}
],
Plot[ gopt[x],
{x,0,20},
RegionFunction->Function[{x,y}, -sopt<(x-mopt)/3<sopt],
Filling->Axis,
PlotLegends->{"Nopt"},
PlotStyle->{Green,Dashed}],
AxesLabel->{"x","F"},
Ticks->None,
Axes->{True,True},
PlotRange->{{0,17},{0,14}}
]
All in order to export it as an .eps image file.
Export["robustdesignFinal.eps",plots]
The two graphs I would like to add are essentially the ones below:
datarob=RandomVariate[NormalDistribution[mrob, srob],10000]
dataopt=RandomVariate[NormalDistribution[mopt, sopt],10000]
Adatarob=f[datarob]
Adataopt=f[dataopt]
h1=SmoothHistogram[ Adatarob,
Automatic,
"PDF",
RegionFunction->Function[{x,y},3.3<x<3.6],
PlotRange->{{3.3,3.6},{0,15}},
Filling->Axis,
PlotLegends->{"P(Frob)"},
PlotStyle->{Red, Dashing[{0.01,0.02}]},
Axes->False
]
h2=SmoothHistogram[ Adataopt,
Automatic,
"PDF",
RegionFunction->Function[{x,y},0<x<10],
PlotRange->{{0,10},{0,0.5}},
Filling->Axis,
PlotLegends->{"P(Fopt)"},
PlotStyle->{Green,Dashing[{0.02,0.04}]},
Axes->False
]
FindMinimum
on that interpolating function, given that you've specified no constraints, which means the minimum is -infinity. $\endgroup$Adatarob
andAdataorb
stuff? $\endgroup$FindMinimum
, firstly i am only interested in this specific region of the function3.95<x<15.5
which demonstrates what i would like to explain in my essay. And secondly the interpolating function results in a 12th degree polynomial, even highest degree, with a positive coefficient forx^12
. So, the minimum is a real number. $\endgroup$