Search code examples
wolfram-mathematicamathematica-8

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.


Solution

  • 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.}
    *)