Gregory Pettigrew (etherial) wrote,
Gregory Pettigrew

  • Mood:
  • Music:

Math Geekery

neuromancerzss asked me a quick math question and it got rosinavs and I geeking about probability. His question was basically, "If I have N coins, each with a different probability PN of coming up heads, what is the probability that Y or more will come up heads?". This problem is trivial if they all have the same PN, and moderately simple if N or Y is small (we're talking Y<=2 here, kids). But I thought "This should be no problem in matlab!"

1. Create an array of all the possibilities for flipping coins (1=heads and -1=tails). One coin looks like
[ 1;

- Two coins looks like -

[ 1 1;
1 -1;
-1 1;
-1 -1]

- Three looks like -

[ 1 1 1;
1 1 -1;
1 -1 1;
-1 1 1;
1 -1 -1;
-1 1 -1;
-1 -1 1;
-1 -1 -1]

Etc., etc. There are N_C_N=1 rows of all 1s at the top, N_C_(N-1)=N rows of all but one heads below it, N_C_(N-2) rows of all but two heads below that, etc. Each row is unique and has at least as many 1s as the row below it.

2. You then multiply each entry by (PN - .5) and add .5 to each entry, resulting in an array with all the probabilities laid out.

3. Multiply the elements of each row to create a column vector giving the probability for that row.

4. Since these are all in order, sum N_C_K from k=Y to N and and take the sum of the top that-many rows, and Presto!, you have P(Y or more are heads). See? Trivial!

And man, did I forget how much I loved matlab. Tonight, I'm going to sit in bed and diagram out the first computer program I've written for myself in a long, long time - the Camelot Chores Generator.

  • The Love of Things

    I love things. I love taking my things out of their boxes, holding them, fiddling with them, recalling previous times I'd played with them, worked…

  • Fantastic Beasts and Where to Find Them

    While I continue to be ticked off at J. K. Rowling for her complete mishandling of Magic in North America, my position on this particular film has…

  • On Third Parties

    I was a paid staffer for Phillies 2008, a Libertarian Party Presidential Campaign. By then, I was already identifying as a Small Government…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded