Re: can Mathematica be useful for this?

*To*: mathgroup at smc.vnet.net*Subject*: [mg56576] Re: can Mathematica be useful for this?*From*: "Kezhao Zhang" <kezhao.zhang at gmail.com>*Date*: Fri, 29 Apr 2005 03:20:50 -0400 (EDT)*References*: <d4kks5$eck$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Here is another approach: For each language, let's use 1 to indicate that the person can speaks it and 0 that he cannot. So a binary vector of length 3 describes what languages the person speaks. For example, {S=1, F=0, G=0}, or {1, 0, 0} means that he can speak Spanish only. The probably corresponding to such vector is denoted by p[S,F,G] (lower case p). All the probabilities listed in the problem are functions of p[S,F,G] (all 8 of them). For example, probability that the person can speak S and F, P[S and F]=p[1,1,0]+p[1,1,1] (note the difference between upper case P and lower case p), etc. We need to write P in terms of p and solve for p which is the answer we need. The probabilities listed in the problem are prob={P[1,0,0],P[0,1,0],P[0,0,1],P[1,1,0],P[0,1,1],P[1,0,1],P[1,1,1]}; unknown=Outer[p,Sequence@@Table[{0,1},{3}]]//Flatten {p[0,0,0],p[0,0,1],p[0,1,0],p[0,1,1],p[1,0,0],p[1,0,1],p[1,1,0],p[1,1,1]} Now write each of them in terms of p: convert[index_P]:=Plus@@Cases[unknown,index/.{P->p,0->_}] p@@@convert[#]&/@prob {p[1,0,0]+p[1,0,1]+p[1,1,0]+p[1,1,1],p[0,1,0]+p[0,1,1]+ p[1,1,0]+p[1,1,1],p[0,0,1]+p[0,1,1]+p[1,0,1]+p[1,1,1],p[1,1,0]+p[1,1,1], p[0,1,1]+p[1,1,1],p[1,0,1]+p[1,1,1],p[1,1,1]} The equation to be solved: eqn=Thread[%=={1/3,26/100,2/10,15/100,5/100,1/10,2/100}]; Plus the condition that all p's sum to 1: Solve for p: sol=Solve[Append[eqn, Total[unknown]==1],unknown] {{p[0,0,0]->73/150,p[0,0,1]->7/100,p[0,1,0]->2/25,p[0,1,1]->3/100,p[1, 0,0]->31/300,p[1,0,1]->2/25,p[1,1,0]->13/100,p[1,1,1]->1/50}} Hence the probability that the person doesn't speak any is p[0,0,0]=73/150, and the probability that he speaks one only is p[0,0,1]+p[1,0,0]+p[0,1,0]/.sol {19/75} K. Zhang