Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

App that counts probabilities in c++

  1. Jan 8, 2014 #1
    Hey,I am making an app that counts probabilities in c++(win32){for those who knows}.
    I have found three formulas of equation,but I need some help for one.

    For example we have a die,and we hit it 6 times.
    Can we count with an formula,the probabilities to have the number "5",three times exactly?(no less,no more)

  2. jcsd
  3. Jan 8, 2014 #2


    User Avatar
    Science Advisor
    Gold Member

    Use the binomial theorem.
    k out of n with probability p of success on one roll (q=1-p), is pkq(n-k)n!/{k!(n-k)!}.
    Your example: n = 6, k = 3, p = 1/6.
  4. Jan 9, 2014 #3
    Can you explain more because I hear about that first time?

    Or you could send me a tutorial??
  5. Jan 9, 2014 #4


    User Avatar
    Science Advisor
    Gold Member

  6. Jan 9, 2014 #5
    Yea,I found an intersting site called "Math is fun",and I undestood it,but how I can count probabilities with that?
  7. Jan 9, 2014 #6


    User Avatar

    Staff: Mentor

    For the example in your original post:

    You cast the die six times, so there are ##6^6## equally likely sequences of results. Because they are equally likely, the probability of getting any given sequence is one in ##6^6##. How many of these sequences include exactly three fives?
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: App that counts probabilities in c++
  1. Counting math (Replies: 0)

  2. Counting (Again) (Replies: 2)

  3. Counting, kinda (Replies: 29)