Hi, The graph range was hard-coded means in the single digits rather than in the double digits, so the plot was "off-the-page" so to speak. I added code to calculate appropriate axes for the graph so the curves show up. I also had trouble with the Integrate() function used here, and settled instead for Riemann sums under the polygon. It will be reasonably accurate this way. Names Default to Here( 1 );
// Define curves and calculate overlap area
mean1 = 46.17;
stdev1 = 16.27;
mean2 = 82.08;
stdev2 = 17.68;
N1 = Expr(Normal Density(x, mean1, stdev1)); N2 = Expr(Normal Density(x, mean2, stdev2));
//––––––––––
// calculate graph ranges
rangemin = Minimum(mean1-6*stdev1,mean2-6*stdev2);
rangemax = Maximum(mean1+6*stdev1,mean2+6*stdev2);
// Illustration
ym = zm = 1 :: 2000; // 2000 has to do with how detailed the plot should be
multiplier = (rangemax-rangemin)/(Maximum(ym)-Minimum(ym));
xm = (ym-Minimum(ym))*multiplier+rangemin;
ovl = 0;
For(i = 1, i <= N Col(xm), i++,
ym[i] = Minimum(Normal Density(xm[i], mean1, stdev1), Normal Density(xm[i], mean2, stdev2));
zm[i] = Maximum(Normal Density(xm[i], mean1, stdev1), Normal Density(xm[i], mean2, stdev2));
If(i>1, ovl += 0.5*(ym[i-1]+ym[i])*(xm[i]-xm[i-1]));
);
New Window("Overlap Coefficient",
y = Graph Box(
Y Scale(0, 1.2*Maximum(zm)),
X Scale(rangemin, rangemax),
Y Function(N1, x);
Y Function(N2, x);
Text({Mean(xm), 0.6*Maximum(zm)}, "OVL% = ", ovl*100);
Fill Color(1);
Polygon(xm, ym);
)
);
... View more