Re: PiecewiseExpand bug?

• To: mathgroup at smc.vnet.net
• Subject: [mg68476] Re: PiecewiseExpand bug?
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Mon, 7 Aug 2006 01:40:30 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <eb45vn\$n7p\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```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: Re: Re: Finding the Number of Pythagorean Triples below a bound
• Next by Date: Re: Re: returning a variable's name, rather than the variable's contents
• Previous by thread: PiecewiseExpand bug?
• Next by thread: Re: PiecewiseExpand bug?