MathGroup Archive 2014

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

Search the Archive

Re: Bug with ProbabilityDistribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132580] Re: Bug with ProbabilityDistribution
  • From: CHARLES GILLINGHAM <cgillingham1 at me.com>
  • Date: Mon, 14 Apr 2014 05:26:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140409081446.CA0646A01@smc.vnet.net>

Found a case where with PiecewiseExpand does not help. Evaluate this:

Piecewise[{{2/3, X == 1 && Y == 1}, {0, X != 0 || Y != 1}}, 1/3];
PiecewiseExpand[%];
ProbabilityDistribution[%, {X, 0, 1, 1}, {Y, 0, 1, 1}];
PDF[%][{1, 0}]

and you get:

Undefined.

MORE:

This is interesting =97 study this example.  On line 5, we have two Mathematica expressions for which SameQ is True, and yet substituting a few symbols produces DIFFERENT results. How is that even possible? What is happening here?

Piecewise[{{2/3, X == 1 && Y == 1}, {0, X != 0 || Y != 1}}, 1/3];
PiecewiseExpand[%];
ProbabilityDistribution[%, {X, 0, 1, 1}, {Y, 0, 1, 1}];
PDF[%][{pX, pY}];
{%, PiecewiseExpand[%]};
%[[1]] ===  %[[2]]
%% /. {pX -> 1, pY -> 0}



On Apr 10, 2014, at 12:08 AM, CHARLES GILLINGHAM <cgillingham1 at me.com> wrote:

> Thanks for the work around. Still seems to me this is a bug.
>
> On Apr 9, 2014, at 6:18 AM, Bob Hanlon <hanlonr357 at gmail.com> wrote:
>
>> Works as expected  if you simplify the Piecewise (PiecewiseExpand) or let the Piecewise default handle the cases where the value is zero. Note that PDF[d][{x1,x2}] can be entered simply as PDF[d,{x1,x2}]
>>
>> d = ProbabilityDistribution[
>>   Piecewise[{
>>      {0, x1 == 1 && x2 == 1},
>>      {1/2, x1 == 1 && x2 == 0},
>>      {0, x1 == 0 && x2 == 1},
>>      {1/2, x1 == 0 && x2 == 0}}] //
>>    PiecewiseExpand,
>>   {x1, 0, 1, 1}, {x2, 0, 1, 1}];
>>
>> t1 = Table[
>>   {x1, x2, PDF[d, {x1, x2}], PDF[d][{x1, x2}]},
>>   {x1, 0, 1}, {x2, 0, 1}] //
>>  Flatten[#, 1] &
>>
>> {{0, 0, 1/2, 1/2}, {0, 1, 0, 0}, {1, 0, 1/2, 1/2},
>>   {1, 1, 0, 0}}
>>
>> d = ProbabilityDistribution[
>>   Piecewise[{
>>     {1/2, x1 == 1 && x2 == 0},
>>     {1/2, x1 == 0 && x2 == 0}}],
>>   {x1, 0, 1, 1}, {x2, 0, 1, 1}];
>>
>> t2 = Table[
>>   {x1, x2, PDF[d, {x1, x2}], PDF[d][{x1, x2}]},
>>   {x1, 0, 1}, {x2, 0, 1}] //
>>  Flatten[#, 1] &
>>
>> {{0, 0, 1/2, 1/2}, {0, 1, 0, 0}, {1, 0, 1/2, 1/2},
>>   {1, 1, 0, 0}}
>>
>> t1 == t2
>>
>> True
>>
>>
>> Bob Hanlon
>>
>>
>>
>> On Wed, Apr 9, 2014 at 4:14 AM, CHARLES GILLINGHAM <cgillingham1 at me.com> wrote:
>> Evaluate this:
>>
>>        ProbabilityDistribution[
>>                Piecewise[{{0, x1 == 1 && x2 == 1}, {1/2, x1 == 1 && x2 == 0}, {0, x1 == 0 && x2 == 1}, {1/2, x1 == 0 && x2 == 0}}],
>>                 {x1, 0, 1, 1}, {x2, 0, 1, 1}
>>         ]
>>        PDF[%][{1, 1}]
>>
>> And you get:
>>
>>        Undefined
>>
>> But the probability is obviously 0
>>
>> Is there something I am misunderstanding about how simple Boolean probability distributions should be set up?
>>
>> Thanks.
>>
>>
>>
>>
>>
>




  • Prev by Date: Re: Redudant code for style purposes?
  • Next by Date: Re: Redudant code for style purposes?
  • Previous by thread: Re: Bug with ProbabilityDistribution
  • Next by thread: Re: Bug with ProbabilityDistribution