MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: EmpiricalDistribution bug

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122976] Re: EmpiricalDistribution bug
  • From: Mark Fisher <particlefilter at gmail.com>
  • Date: Sat, 19 Nov 2011 06:45:37 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <ja5f74$6b8$1@smc.vnet.net>

On Nov 18, 6:23 am, Mark Fisher <particlefil... at gmail.com> wrote:
> Here is a (bad) bug involving EmpriicalDistribution:
>
> PDF[EmpiricalDistribution[{1}], 1]
>
> produces error messages and returns
>
> Boole[{1}[[GeometricFunctions`BinarySearch[{{1}, "Sorted"}, 1]]] ==
>    1] {1}[[GeometricFunctions`BinarySearch[{{1}, "Sorted"}, 1]]]
>
> Here is an (awkward) workaround:
>
> PDF[EmpiricalDistribution[{1}], x] /. x -> 1
>
> which returns 1.
>
> I have submitted this to supp... at wolfram.com, but I'm hoping someone
> lurking from wolfram will look into this and figure out a code patch
> that can be applied right away. Thanks.
>
> --Mark
>
> "8.0 for Microsoft Windows (64-bit) (October 7, 2011)"

I got an answer from Andy Ross at Wolfram support:

"This is a known issue that has been resolved for future versions of
Mathematica but unfortunately didn't make it in for 8.0.4. In the
meantime you can use the following code which should fix the problem.

GeometricFunctions`BinarySearch;
Unprotect[GeometricFunctions`BinarySearch];
GeometricFunctions`BinarySearch[{{d_?NumericQ},"Sorted"},x_?
NumericQ]:=Which[x<d,0,x==d,1,True,2];
Protect[GeometricFunctions`BinarySearch];

It is possible (though unlikely) that this could have some unintended
consequences in other parts of Mathematica so only use it if you
really need it."

The patch works but of course I don't know what it might break.

--Mark





  • Prev by Date: Re: Help needed - Mathematica code
  • Next by Date: Data binning with CUDA
  • Previous by thread: Re: EmpiricalDistribution bug
  • Next by thread: Re: EmpiricalDistribution bug