MathGroup Archive 2004

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

Search the Archive

Re: Experimentian with Bayesian statistics


NA <nospam at here.com> wrote in message news:<bt8o98$c1u$1 at smc.vnet.net>...
> Hi,
> I'm trying to learn some basic Bayesian statistics with Mathematica but I'm
> having trouble building up the probability formulae that I need.
> 
> I tried to define
> 
> depPr[x_,y_] := (Pr[x] depPr[y,x]) / Pr[y]
> 
> but I don't even get an Out result  (I thought it would have at least
> redisplayed it with numerator over denominator)
> 
> (I assumed by the way that I needed a different name for the function   Pr{x
> | y} vs the simple  Pr{x})
> 
> 
> If I replace the ':=' with '=', then I just get a recursion error.
> 
[...]
This is an example of what you could do to prevent recursion :

In[1]:=ClearAll[p];
   p[a_[r_Integer(* event number *), n_Integer(* number of events *)],b_]:=
   p[b,a[r,n]]p[a[r,n]] / Sum[p[b,a[i,n]]p[a[i,n]],{i,1,n}];

Numeric example :

In[2]:=
   p[a[1,2]] = 1/10;
   p[a[2,2]] = 9/10;
   p[b,a[1,2]] = 1/3;
   p[b,a[2,2]] = 1/60;

In[3]:=p[a[1,2],b]

Out[3]=20/29

In[4]:=p[a[2,2],b]

Out[4]=9/29

hth
---
jcp


  • Prev by Date: Quantum algebra package
  • Next by Date: Re: Mathematica exports curves in pieces to Illustrator
  • Previous by thread: Experimentian with Bayesian statistics
  • Next by thread: Interpolating function