Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: PiecewiseExpand bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68500] Re: PiecewiseExpand bug?
  • From: Mark Fisher <mark at markfisher.net>
  • Date: Tue, 8 Aug 2006 06:28:36 -0400 (EDT)
  • References: <eb45vn$n7p$1@smc.vnet.net> <eb6k48$nlh$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Let me put it slightly differently:

expr1 = Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}];
expr2 = PiecewiseExpand[expr1];
Simplify[expr1 == expr2]

produces

p^2 == p || x[1] != 0 || x[2] != 1 || x[3] != 1

so that if

x[1] == 0 && x[2] == 1 && x[3] == 1 && p^2 != p

then expr1 and expr2 are not the same!

Therefore, if PiecewiseExpand is *not* supposed to change the what the 
expression evaluates to, then this would seem to be a bug.

--Mark.


Jean-Marc Gulliet wrote:
> Mark Fisher wrote:
>> This produces what I expect:
>>
>> Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}] /.
>> 	{x[1] -> 0, x[2] -> 1, x[3] -> 1}
>>
>> But this does not:
>>
>> PiecewiseExpand[Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}]] /.
>> 	{x[1] -> 0, x[2] -> 1, x[3] -> 1}
>>
>> It appears PiecewiseExpand does something it shouldn't here. Any thoughts?
> 
> No, it does not: you are not computing the same expressions because of 
> the location of the transformation rules. You can clearly see what's 
> going on with the Trace function if needed.
> 
> In[1]:=
> << "Statistics`DiscreteDistributions`"
> 
> In[2]:=
> Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}] /. {x[1] -> 0, x[2] 
> -> 1, x[3] -> 1}
> 
> Out[2]=
> (1 - p)*p^2
> 
> In[3]:=
> PiecewiseExpand[Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}]] /. 
> {x[1] -> 0, x[2] -> 1, x[3] -> 1}
> 
> Out[3]=
> 0
> 
> In[4]:=
> PiecewiseExpand[Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}] /. 
> {x[1] -> 0, x[2] -> 1, x[3] -> 1}]
> 
> Out[4]=
> (1 - p)*p^2
> 
> In[5]:=
> PiecewiseExpand[(1 - p)*p^2]
> 
> Out[5]=
> (1 - p)*p^2
> 
> In[6]:=
> Trace[Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}] /. {x[1] -> 
> 0, x[2] -> 1, x[3] -> 1}]
> 
> In[7]:=
> Trace[PiecewiseExpand[Product[PDF[BernoulliDistribution[p], x[i]], {i, 
> 3}]] /. {x[1] -> 0, x[2] -> 1, x[3] -> 1}]
> 
> Regards,
> Jean-Marc
> 


  • Prev by Date: Newbie question about column sums of arrays
  • Next by Date: Re: Two strange problems with a notebook...
  • Previous by thread: Re: PiecewiseExpand bug?
  • Next by thread: Re: PiecewiseExpand bug?