       Re: can Mathematica be useful for this?

• To: mathgroup at smc.vnet.net
• Subject: [mg56505] Re: [mg56457] can Mathematica be useful for this?
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Tue, 26 Apr 2005 21:54:02 -0400 (EDT)
• References: <200504260533.BAA14385@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On 26 Apr 2005, at 14:33, pedrito6 at softhome.net wrote:

> *This message was transferred with a trial version of CommuniGate(tm)
> Pro*
> Hi there!
>
> I need to check the answer of many probability problems.
> Most of them are quite simple but calculating them by hand is tedious.
>
> They are like this:
> "It's necessary to choose a person for a mission overseas. If you
> choose
> him randomly the probability that he speaks a foreign languague is:
> S=Spanish; F=French; G=German
> P(S)=0.33;     P(F)=0,26;      P(G)=0.2;
> P(S and F)=0.15;     P(F and G)=0.05;     P(S and G)=0.1
> P(S and F and G)=0.02
>
>  -What is the probability that he just speaks one foreign language?
>  -What is the probability that he doesn't speak any?"
>
> Could be Mathematica useful for solving this kind of problems?
>
> Thanks for your help!

It can certainly be useful, e.g. in the sense that it will do your
arithmetic for you. You can also automate some computations but how
effective this will be will depend on how much prior programming you do
and on the type of problem. Here is a very simple example of what might
be done.
We implement a simple probability measure p. We use the logical
functions Or and And for the Union and Intersection of events. Our
probability function p satisfies the following rules:

p[True] = 1; p[False] = 0;

p[Or[A_,B_]]:=p[A]+p[B]-p[LogicalExpand[And[A,B]]];

p[Not[A_]]:=1-p[A];

p[HoldPattern[And[X__]]]/;Not[OrderedQ[{X}]]:=p[And@@(Sort[{X}])]

We also use the data which you provided, where I rationalised the
probabilities to make Mathematica use exact arithmetic.

p[S] = 1/3; p[F] = 26/100; p[G] = 2/10; p[F && S] = 15/100; p[F && G] =
5/100;
p[G && S] = 1/10; p[F && G && S] = 2/100;

Now some probabilities can be computed automatically. The event that
the chosen person speaks at least one language is Or[S,F,G] and this is

p[S || F || G]

77/150

This means that we know the answer to the second question; the
probability that he speaks no foreign languages is:

p[ !(F || S || G)]

73/150

The first question is slightly more difficult. The probability that a
person speaks at least one language is the disjoint union of the events
that he speaks exactly one language, exactly two languages and exactly
three languages. We are given the probability that he speaks exactly
three p[F && G && S]. Let's first compute the probability that he
speaks exactly two. This event is the disjoint union of three events F
&& S &&  !G ,   F && G &&  !S and G && S &&  !F. We know that the even
F && S is the disjoint union of F && S && G and F && S && !G , etc. So
using the equalities:
F && S == (F && G && S) || (F && S &&  !G)], F && G == (F && G && S) ||
(F && G &&  !S) and G && S = (G && S && F) || (G &&S && !F) we get

Simplify[Simplify[p[F && S] ==
p[(F && G && S) || (F && S &&  !G)]]]

100*p[F && S &&  !G] == 13

Simplify[p[F && G] == p[(F && G && S) || (F && G &&  !S)]]

100*p[F && G &&  !S] == 3

Simplify[p[G && S] == p[(G && S && F) || (G && S &&  !F)]]

25*p[G && S &&  !F] == 2

So the probability that he speaks exactly one language is:

77/150 - 2/100 - 13/100 - 3/100 - 2/25

19/75

One could try to automate these computations further, possibly by
introducing conditional probability p[A,B] and maybe using backtracking
but this is too complicated and time consuming to consider here.

Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/andrzej/index.html
http://www.mimuw.edu.pl/~akoz/

```

• Prev by Date: Re: Mathlink memory preservation
• Next by Date: Re: "large" matrices, Eigenvalues, determinants, characteristic polynomials
• Previous by thread: can Mathematica be useful for this?
• Next by thread: Re: Re: can Mathematica be useful for this?