C/C++ App that counts probabilities in c++

AI Thread Summary
The discussion revolves around calculating the probability of rolling a specific number, in this case, "5," exactly three times when rolling a die six times. The binomial theorem is suggested as the method to solve this problem. The relevant formula is presented as pkq(n-k)n!/{k!(n-k)!}, where n represents the total number of rolls (6), k is the number of successful outcomes (3), and p is the probability of success on a single roll (1/6 for rolling a "5"). Participants emphasize the importance of understanding the binomial distribution, directing the original poster to resources like Wikipedia and "Math is Fun" for further learning. The conversation highlights that there are 6^6 possible outcomes when rolling a die six times, and the challenge is to determine how many of these outcomes result in exactly three occurrences of the number "5." This foundational understanding of probability and the binomial distribution is crucial for developing the app in C++.
Hepic
Messages
118
Reaction score
0
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)

Thanks!
 
Technology news on Phys.org
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.
 
Can you explain more because I hear about that first time?

Or you could send me a tutorial??
 
Yea,I found an intersting site called "Math is fun",and I undestood it,but how I can count probabilities with that?
 
Hepic said:
Yea,I found an intersting site called "Math is fun",and I undestood it,but how I can count probabilities with that?

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?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top