       Re: Area Under Curve (Min Length Interval)

• To: mathgroup at smc.vnet.net
• Subject: [mg53900] Re: [mg53889] Area Under Curve (Min Length Interval)
• From: Chris Chiasson <chris.chiasson at gmail.com>
• Date: Wed, 2 Feb 2005 18:10:41 -0500 (EST)
• References: <200502021125.GAA28978@smc.vnet.net>
• Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
• Sender: owner-wri-mathgroup at wolfram.com

```I think Bruce's code would usually work, but Minimize isn't able to
pick up on what is happening or what you want; I'm not sure which.
Anyway, here are a few lines of code that graphically demonstrate what
is happening and give the (locally) correct solution.

<< Statistics`ContinuousDistributions`
F[x_] = CDF[ChiSquareDistribution, x];
NMinimize[{b - a, F[b] - F[a] == 93/100, b > a > 0}, {a, b}]
tempsoln = Solve[F[b] - F[a] == 93/100, b][[1, 1]]
intersectingsurfaces = Plot3D[#, {a, 0, 2}, {b, 0, 40}, AxesLabel -> {"a",
"b", "c"}, DisplayFunction -> Identity] & /@ {F[b] - F[a], 0.93}
Show[intersectingsurfaces,
ViewPoint -> {0, 0, 1}, DisplayFunction -> \$DisplayFunction]
Plot[Evaluate[b /. tempsoln], {a, 0, 1.3}, AxesLabel -> {"a", "b"}]
Plot[Evaluate[b - a /. tempsoln], {a, 0, 1.3}, AxesLabel -> {"a", "b-a"}]
NMinimize[{b - a /. tempsoln, b > a > 0}, {a, b}]

For clarity, these commands may be evaluated one at a time.

Regards,

On Wed, 2 Feb 2005 06:25:53 -0500 (EST), Bruce Colletti
<vze269bv at verizon.net> wrote:
> Re Mathematica 5.1.
>
> How would I compute the minimum length interval over which the area under f(x) is given?
>
> For instance, as shown below, f(x) is the PDF of a chi-square distributed random variable whose CDF is F[x].  Seeking the minimum length 93%-interval [a,b], the code returns "Obtained solution does not satisfy the following constraints within Tolerance -> 0.001..."  Fiddling with options has been futile.
>
> Any ideas?  Thankx.
>
> Bruce
>
> F[x_] := CDF[ChiSquareDistribution, x]
>
> Minimize[{b - a, F[b] - F[a] == 0.93, b > a > 0}, {a, b}]
>
> NMinimize[{b - a, F[b] - F[a] == 0.93, b > a > 0}, {a, b}]
>
>

--
Chris Chiasson
Kettering University
Mechanical Engineering