Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Is an online coin flipper really 50/50, or am I overthinking it?

kemiy

Bronze Coder
Hey everyone,

My friends and I have a running habit of settling small disagreements with a flip, like who pays for lunch or who picks the movie. Lately we've started using a digital tool instead of carrying real coins, and now someone claims it's rigged.

Honestly, I'm not sure how a coin flipper actually works behind the scenes. Is it using true randomness, or just a pseudo-random algorithm that could favor one side over time? Also, does it matter for casual decisions, or only for serious uses like games and giveaways?

Has anyone tested one over hundreds of flips? I'd love to hear your experiences and recommendations.
 
Hey everyone,

My friends and I have a running habit of settling small disagreements with a flip, like who pays for lunch or who picks the movie. Lately we've started using a digital tool instead of carrying real coins, and now someone claims it's rigged.

Honestly, I'm not sure how a coin flipper actually works behind the scenes. Is it using true randomness, or just a pseudo-random algorithm that could favor one side over time? Also, does it matter for casual decisions, or only for serious uses like games and giveaways?

Has anyone tested one over hundreds of flips? I'd love to hear your experiences and recommendations.
thanks in advance for any help
 
If you suspect a coin is biased, there is a cute way around it. Flip twice.

H T : win
T H : lose
H H : flip again
T T : flip again

Doesn't matter what the probabilities for H and T are. H * T = T * H.

I notice you post on a wide range of subjects, are you some kind of marketing bot?
 
I think you're overthinking it a little 😂 A fair coin flipper should give roughly 50/50 results over many flips, but getting several heads or tails in a row is completely normal. Have you noticed one side coming up more often?
 
Hey everyone,

My friends and I have a running habit of settling small disagreements with a flip, like who pays for lunch or who picks the movie. Lately we've started using a digital tool instead of carrying real coins, and now someone claims it's rigged.

Honestly, I'm not sure how a coin flipper actually works behind the scenes. Is it using true randomness, or just a pseudo-random algorithm that could favor one side over time? Also, does it matter for casual decisions, or only for serious uses like games and giveaways?

Has anyone tested one over hundreds of flips? I'd love to hear your experiences and recommendations.
Most digital coin flippers use a pseudo-random number generator, although some use physical sources of randomness. A good generator should give heads and tails equal probability, but no finite sequence is guaranteed to contain exactly 50% of each.

Even hundreds of flips can produce noticeable deviations without anything being wrong. The important question is not whether the results look perfectly balanced, but whether the generator has a systematic bias.

For lunch and movie choices, a decent digital coin flipper is perfectly adequate. The real challenge is convincing the person who loses!
 
It is not true randomnes, but as close as computer can get to it.

And if you test it with anything less than at least thousands of rounds to get the average, you do not get reasonable results. To find real bias, you need millions of rounds to see it.

Easiest way to understand this is roulette. Black, White, Black, White and roughly every 36th turn a green zero, right? Still we daily see how red comes up 16 times in a row, then one black and then like 10 red ones again. Ratio is 26 reds and 1 black, but its not a bias.

If you are playing black, you believe the game is rigged while it is just a normal variation that happens daily, several times. The one who plays red thinks he has some superpower to know when red comes and later that day, he loses his moneys.

Here is a quick python script. It throws a coin 100 times and outputs the results.
How ever, if either one gets +9 a head, it stops.


Python:
import random

heads = 0
tails = 0
max_throws = 100
stop_diff = 9

for throw in range(1, max_throws + 1):
  result = random.choice(["heads", "tails"])

  if result == "heads":
    heads += 1
  else:
    tails += 1

  if abs(heads - tails) >= stop_diff:
    print(f"Execution was interrupted with throw {throw} because the difference increased to {stop_diff} throw.")
    break

print(f"Heads: {heads}")
print(f"Tails: {tails}")

Out of 5 runs, 4 times stop early since one results got so much a head.
Code:
PS C:\Users\ekvir\Downloads> py .\coin.py
Execution was interrupted with throw 33 because the difference increased to 9 throw.
Heads: 12
Tails: 21
PS C:\Users\ekvir\Downloads> py .\coin.py
Heads: 52
Tails: 48
PS C:\Users\ekvir\Downloads> py .\coin.py
Execution was interrupted with throw 13 because the difference increased to 9 throw.
Heads: 2
Tails: 11
PS C:\Users\ekvir\Downloads> py .\coin.py
Execution was interrupted with throw 37 because the difference increased to 9 throw.
Heads: 23
Tails: 14
PS C:\Users\ekvir\Downloads> py .\coin.py
Execution was interrupted with throw 33 because the difference increased to 9 throw.
Heads: 12
Tails: 21

At shortets, it stopped at round 13, after 2 heads and 11 tails.
 
Back
Top Bottom