Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using NProbability[] or Probability[] to work out the probability of 3 or more Heads from 4 coin tosses

Is it possible to work out the probability of 3 or more Head from 4 coin tosses using the Probability or NProbability functions.

This is not a question about the trivial answer to this problem, it is more to get an understanding of how to solve this kind of problem with Mathematica using distributions.

So using 4 random variables from Distribution P

I was hoping something like this would do the trick, but it does not work. I get 0.

P = BernoulliDistribution[0.5];
vars = List[Distributed[a,P],Distributed[b,P],Distributed[c,P],Distributed[c,P]];
NProbability[Count[ {a,b,c,d}, 1] >= 3,  vars]

Any ideas would be greatly appreciated.

like image 362
Bart Avatar asked Oct 19 '11 12:10

Bart


2 Answers

Not an expert using Mma for statistics here, but this seems to work:

l = TransformedDistribution[
       x + y + w + z, {x \[Distributed] BernoulliDistribution[0.5], 
                       y \[Distributed] BernoulliDistribution[0.5], 
                       z \[Distributed] BernoulliDistribution[0.5], 
                       w \[Distributed] BernoulliDistribution[0.5]}];

Table[NProbability[x > i, x \[Distributed] l], {i, -1, 4}]
(*
{1, 0.9375, 0.6875, 0.3125, 0.0625, 0.}
*)
like image 89
Dr. belisarius Avatar answered Nov 08 '22 05:11

Dr. belisarius


In[10]:= Probability[a + b + c + d >= 3, vars]

Out[10]= 0.3125

Coin flipping is easier described with a BinomialDistribution:

In[12]:= Probability[m >= 3, m \[Distributed] BinomialDistribution[4, 0.5]]

Out[12]= 0.3125
like image 25
Sjoerd C. de Vries Avatar answered Nov 08 '22 07:11

Sjoerd C. de Vries