X-Received: by 10.182.186.105 with SMTP id fj9mr10650098obc.5.1397196922318; Thu, 10 Apr 2014 23:15:22 -0700 (PDT) MIME-Version: 1.0 Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!ur14no6100847igb.0!news-out.google.com!du2ni6892qab.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: CHARLES GILLINGHAM Newsgroups: comp.soft-sys.math.mathematica Subject: Re: Bug with ProbabilityDistribution Date: Fri, 11 Apr 2014 06:08:34 +0000 (UTC) Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator Message-ID: References: <20140410070657.9900D69EE@smc.vnet.net> Lines: 33 Organization: Time-Warner Telecom NNTP-Posting-Date: 11 Apr 2014 06:14:33 GMT NNTP-Posting-Host: 75ca9f1c.news.twtelecom.net X-Trace: DXC=jK@^90T]7OGcn?\5K_?h9OC_A=>8kQj6M;[h;PUXBgbDPm3bW^Q9cmFEFiONJ7[GoF53:>a\;SE6A X-Complaints-To: abuse@twtelecom.net Xref: csiph.com comp.soft-sys.math.mathematica:16770 On Apr 10, 2014, at 12:06 AM, Bill Rowe wrote: > On 4/9/14 at 4:14 AM, cgillingham1@me.com (CHARLES GILLINGHAM) 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} >> ] > > Start with a fresh session and pay attention to the syntax > coloring. Note that x1 and x2 are undefined and your syntax does > not make these local variables. That is entering > > f[x_]:=2 x > > will cause x to be colored differently than your x1, x2 above. > > You get undefined as a result since x1 and x2 are never defined. This is an interesting issue (that may point to other problems), but it doesn't explain the particular bug I am looking at. The variables are also undefined in Bob Hanlon's workaround. Try this, which is exactly equivalent, and works fine: ProbabilityDistribution[ Piecewise[{{0, (x1 != 0 && x1 != 1) || x2 != 0}}, 1/2] , {x1, 0, 1, 1}, {x2, 0, 1, 1}] PDF[%][{1,1}]