Calculating Probabilities with Visual Basic: A Practical Guide

  • Context: Undergrad 
  • Thread starter Thread starter JPC
  • Start date Start date
  • Tags Tags
    Probability
Click For Summary

Discussion Overview

The discussion revolves around calculating the probability of obtaining exactly 50 heads and 50 tails when tossing a fair coin 100 times. Participants explore the underlying concepts of probability, particularly focusing on the binomial distribution and factorial calculations.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • Some participants clarify that the probability of getting exactly 50 heads in 100 tosses can be modeled using a binomial distribution, specifically X~Bin(100,0.5).
  • Others discuss the formula for calculating this probability, which involves factorials and the binomial coefficient.
  • A participant expresses confusion about the notation and operations involved in the probability formula, questioning the lack of operators between terms.
  • Some participants correct earlier misunderstandings about factorial notation, emphasizing that it represents multiplication rather than addition.
  • There are discussions about approximation methods for calculating factorials and the complexities involved in computing large factorials directly.
  • A suggestion is made to use Visual Basic to automate the calculations for probabilities involving large numbers of trials.

Areas of Agreement / Disagreement

Participants generally agree on the use of the binomial distribution for this problem, but there is no consensus on the clarity of the mathematical expressions and operations involved. Confusion remains regarding the factorial calculations and their implications.

Contextual Notes

Limitations include unresolved questions about the notation and operations in the probability formula, as well as the complexity of calculating large factorials directly. The discussion also highlights the need for clarity in mathematical conventions.

Who May Find This Useful

This discussion may be useful for individuals interested in probability theory, mathematical modeling, or programming solutions for statistical calculations.

JPC
Messages
204
Reaction score
1
Hey, let's take for example the probabilities when u throw 100 times a coin (lets say it can't be corner)

ok , the probability is obviously 50 : 50

but , what's the probability that your results are same as the probability for this case
 
Physics news on Phys.org
The probability of what is '50 : 50' ? :wink:
 
well

well if u throw 100 times a coin
the probability is : 50 heads, 50 tails
 
In other words, you want the probability of throwing exactly 50 heads (and 50 tails) in 100 tosses, any order of heads and tails.

Is this homework? If so, please show what you have done. If not, I (or someone else here) will show you how to compute such a probability.
 
JPC said:
well

well if u throw 100 times a coin
the probability is : 50 heads, 50 tails

Not for any coin. Only for an unbiased coin P(Head)=P(Tail) in a single toss = 0.5, assuming that there is no other outcome of the toss.
Getting 50 heads and 50 tails is an event, it is not a probability.
Again, if P(H)=0.5 then "50 heads" is the "expected" number of heads in 100 throws...it is not a probability.
Now coming to your question: If you denote the no. of heads in 100 tosses by X, then X~Bin(100,0.5). Find P(X=50).
 
Last edited:
ssd said:
If you denote the no. of heads in 100 tosses by X, then X~Bin(100,0.5). Find P(X=50).

What does that mean , i don'k know all the conventions yet ?

and its not for homework
 
ssd was talking about random variables. You may want to google-up that term.
 
In particular, ssd was talking about a random variable with a binomial probability distribution, which applies only if the coin is unbiased and tosses are independent. Assuming an unbiased coin and indepdendent tosses, the answer to the original question is
[tex]\frac{100!}{50!\,50!}\;\frac 1 {2^{100}} \approx 0.0796[/tex]
 
D H said:
In particular, ssd was talking about a random variable with a binomial probability distribution, which applies only if the coin is unbiased and tosses are independent. Assuming an unbiased coin and indepdendent tosses, the answer to the original question is
[tex]\frac{100!}{50!\,50!}\;\frac 1 {2^{100}} \approx 0.0796[/tex]

Right you are. I did not mention the fact that the sum of Bernoullian trials will be Binomial if those trials are independent. Actually I really was focused on the statement of the problem.
 
Last edited:
  • #10
hey , u didnt put any operator between the 50! and 50!
is it multiply ?

and , u didnt put any operator between the two fractions, is it also multiply ?

because , if it is , doesn't look very much like 0.0796

100! : 5050
50! : 1275
50!² : 1625625

5050 / (1625625 * 2^100) = 2.45...and, also, in general terms, what is the logic between this equation ?
 
Last edited:
  • #11
I'm not that good at probability, but the vinculum affects the order of operations, i.e.
[tex]\frac{100!}{50!50!} \frac{1}{2^{100}} = ( 100! / 50!50! ) * ( 1 / 2^{100} ) = 0.0795892374[/tex]
 
Last edited:
  • #12
JPC said:
because , if it is , doesn't look very much like 0.0796

100! : 5050
50! : 1275
50!² : 1625625

5050 / (1625625 * 2^100) = 2.45...

Wha...? 50! is a huge number with 65 digits, it's a lot bigger than 1275. 1275 = 50 + 49 + ... + 2 + 1, while 50! = 50 * 49 * ... * 2 * 1.
 
  • #13
oh damn , i made a mistake
the ! is a multiplication , not addition, not 0.5(n² + n)

i see my mistake
 
  • #14
but , how do u translate x! then ?

like what's the equation to find it
like if u want to find the sum of all the numbers from 0 to x its : 0.5(x + x²)
but what is it for the multiplication ?
 
  • #15
JPC said:
but , how do u translate x! then ?

like what's the equation to find it
like if u want to find the sum of all the numbers from 0 to x its : 0.5(x + x²)
but what is it for the multiplication ?

There's no polynomial that gives a value close (for any reasonable definition of "close") to x! for all positive x.

There are some approximation formulas; (x/e)^x ~ x! would be one of the simplest*, where e = 2.71828...

If you want the exact answer you're just going to have to multiply it out, though. For this problem that's pretty much all you can do. Notice, though, that 100!/50! = 100 * 99 * ... * 51 * 50 * 49 * ... * 2 * 1 / (50 * 49 * ... * 2 * 1) = 100 * 99 * ... * 52 * 51.

* I hope I got this right, it's from memory. There are much better ones if you need more accuracy; Gosper's reformulation of Stirling's estimate is pretty good.
 
  • #16
better solution (if x is smaller than 1 million)
learn visual Basics , and make a program to do it for you using 'do until' - 'loop'


But what's the logic in that equation ?
how can i make an equation like that for other cases ?
whats the clear syntax ?
 
Last edited:

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K
Replies
33
Views
3K
  • · Replies 126 ·
5
Replies
126
Views
9K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 15 ·
Replies
15
Views
4K