Questions tagged [coin-flipping]

Coin flipping is the process of programmatically simulating a coin flip, that is randomly picking a choice among two possibilities.

Coin flipping is the process of programmatically simulating a coin flip, that is randomly picking a choice among two possibilities.

118 questions
0
votes
5 answers

coin flip generator

what do you guys think will be the outcome if a program is coded to simulate a coin flip where there is a 50% of the coin landing either heads or tails when the results are looked at; Mainly will there be a higher % of the coin flips landing heads…
Juan Velez
  • 729
  • 5
  • 13
  • 29
0
votes
6 answers

Simple recursion problem

I'm taking my first steps into recursion and dynamic programming and have a question about forming subproblems to model the recursion. Problem: How many different ways are there to flip a fair coin 5 times and not have three or more heads in…
Auburnate
  • 417
  • 1
  • 4
  • 11
0
votes
1 answer

Want to generate 100 samples and label each sample as 0 or 1 based on a coin flip R

I want to generate a 100 samples and then assign each sample a label of either a 0 or 1 based on a randomized coin flip. So if I flip heads, then I assign the sample a 0 and for tails I would assign the sample a 1. So far I have: n = 100 for (ii in…
0
votes
2 answers

Infinite loop in coin-flipping game

Consider the following coin-flipping game: A single play of the game consists of repeatedly flipping a fair coin until the difference between the number of heads tossed and the number of tails is 4. You are required to pay 1 dollar for each flip of…
0
votes
1 answer

Need a weighted coin flip function between 2 intervals

My problem is as follows and the code below is what I have so far def log_upload_weighted_coin_flip(current_percent, lower_likelihood=1/11, upper_likelihood=1/1.5, lower_percent=60, upper_percent=99): likelihood_index = upper_likelihood -…
Srini
  • 1,536
  • 1
  • 18
  • 32
0
votes
0 answers

Coin tossing and generating graphs

Could someone generate those graphs or at least help me with that ? I want to generate that probability of getting heads and tails in a undetermined number of flips. Actually its not like that but consider pthetaGivenData like this and check my…
0
votes
0 answers

Codechef problem solution showing NZEC error while using python

I am supposed to write a program that can eventually print the number of Tails or Heads depending on the input. I have written the program and the output is coming correct too when I try to use my own inputs, but codechef throws me a Runtime…
smish_
  • 35
  • 4
0
votes
3 answers

How can I solve the output error in flipping a coin?

I am writing code about the probability of flipping a coin as follows, but I keep getting errors. import random tries = 0 number = random.randint(0, 1) def coin_probability(hehe): for a in range(1, 101): heads = 0; tails = 0 …
Pia
  • 1
  • 3
0
votes
0 answers

Plotting log likelihood of bernoulli distribution

I have a dataset containing the results of 10 fair coin tosses for 5 different students. The formula that I found for the log likelihood is ∑i=1n log p**X_i(1-p)**1-X_i How can I plot this in R ? my values are [8,8,4,5,6] and probability is 0.5 (p =…
0
votes
2 answers

Random walk simulation based on the flipping of a biased coin 100 times

I'm starting in Python. I'm trying to make a simulation of a random walk in a straight line (north and south) based on flipping a biased coin 100 times with 0.3 chance of getting tails and 0.7 chance of getting heads assuming that the values from…
0
votes
1 answer

How to simulate a coin flip with While... Wend and Do... Until?

Develop a solution to flip a coin a given amount of times and then print the number of heads and the number of tail. The equation to toss the coin is Coin = Integer(random*2) + 1 When Coin = 1 the toss is heads, and when Coin = 2 the toss is…
0
votes
3 answers

Coin Flipping Counting Game C++ Data Structure!

Here is the question. In the game, there is a rectangular grid of coins, with heads =1 and tails = 0. The game has one simple rule: the player cannot flip a single coin, instead, the player can choose one row (or one column) and flip all the coins…
0
votes
1 answer

plotting a Monte Carlo simulation in R

I am trying to create a plot that graph a Monte Carlo simulation of a coin toss with iterations on x and probability on y. However, I am having difficulty creating the necessary function. So far I have set.seed(2738952) coins<-function(n){ …
0
votes
1 answer

Coin Flip with Numpy confusion

I'm in the process of learning python and numpy, etc. I'm working on a coding a coin flip, however I'm confused about the code somewhat. I went back through the lesson, but don't see where it explains why total_sums is equal to 2 in the following…
user9762321
  • 83
  • 1
  • 7
0
votes
3 answers

Javascript Submit Button Random Coin Toss

Hopefully this is a quick fix. I have a coin toss generator that functions correctly (yay!) But I would like to be able to hit the flip button multiple times and run the function without having to reload and refresh the page. var randomNumber =…
Blen6035
  • 45
  • 5