[Date Index]
[Thread Index]
[Author Index]
Re: Re: Number of interval Intersections for a large number of intervals
*To*: mathgroup at smc.vnet.net
*Subject*: [mg81751] Re: [mg81718] Re: [mg81679] Number of interval Intersections for a large number of intervals
*From*: Brett Champion <brettc at wolfram.com>
*Date*: Wed, 3 Oct 2007 02:21:09 -0400 (EDT)
*References*: <4236415.1191246194428.JavaMail.root@m35> <200710020936.FAA28508@smc.vnet.net>
On Oct 2, 2007, at 4:36 AM , DrMajorBob wrote:
> [WRI: there's a Plot/Piecewise insect (bug?) noted below.]
>
> I'm having to guess a bit, but maybe this is what you mean:
>
> intervals = Sort /@ RandomReal[{-1, 1}, {10^5, 2}];
> trans = Transpose@intervals;
> {{min, maxLow}, {minHigh, max}} = Through[{Min, Max}@#] & /@ trans;
> {low, high} =
> Interpolation[Transpose@{Sort@#, -1 + Range@Length@#},
> InterpolationOrder -> 0] & /@ trans;
>
> Clear[count]
> count[x_] /; x < min = 0;
> count[x_] /; x > max = 0;
> count[x_] /; x < minHigh := low[x]
> count[x_] /; x > maxLow := low[maxLow] - high[x]
> count[x_] := low[x] - high[x];
> First@Timing@Plot[count@x, {x, -1, 1}]
>
> 0.031
>
> or
>
> Clear[count2]
> count2[x_] =
> Piecewise[{{0, x < min}, {low[x], x < minHigh}, {low[x] - high[x],
> x <= maxLow}, {low[maxLow] - high[x], x <= max}}];
> First@Timing@Plot[count2@x, {x, -1, 1}]
>
> 0.047
>
> INSECT report: If I use a small number of Intervals -- 10, say --
> the two
> plots are different. The Piecewise version doesn't have "returns"
> at some
> of the discontinuities, even though the following plots the zero
> function
> as expected:
>
> Plot[count2@x - count@x, {x, -1, 1}]
>
> Is this an example of Exclusions->Automatic at work?
>
> If so, why aren't all the returns omitted?
>
Conditional definitions of functions, such as used to define count[],
are not detected by the automatic calculation of exclusions. I don't
think this is a bug, although it is an interesting idea.
In the case of count2[], there are only going to be exclusions at the
Piecewise boundaries: x==min, x==max, x==minHigh, x==maxLow. The
interpolating function used by low[] and high[] will be a black box
to it.
Brett Champion
Wolfram Research
Prev by Date:
**Re: Strange Laplace Transform in 6.0**
Next by Date:
** Re: Install problem, 6.0, Mac OS 10.4.10: No kernel connect?**
Previous by thread:
**Re: Number of interval Intersections for a large number of intervals**
Next by thread:
**Re: Re: Number of interval Intersections for a large number of intervals**
| |