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
1
vote
1 answer

Compute the posterior probability given a Bernoulli distributed likelihood

In a coin flip, we would like to compute p(theta|Data), where theta is the underlying parameter. The prior follows a beta distribution with parameters a and b. The likelihood follows a Bernoulli distribution which gives us the probability of…
Salma Bouzid
  • 45
  • 1
  • 9
1
vote
2 answers

Coin Flip Game function

I am trying to create a function in python where a player starts with a certain amount and then given a certain stake and number of flips it will give the ending amount after the flips I am a beginner at python and am still getting used to using…
Rito Lowe
  • 23
  • 2
1
vote
1 answer

Displaying multiple images via setInterval very slow in browsers

I'm trying to simulate a coin flip with javascript. It keeps changing images with 4 positions, creating an impression of flipping for 5 seconds and then sets the source to either the "head" image or "tails" image. I ran it in thimble mozilla and it…
1
vote
1 answer

Iteration performance

I made a function to evaluate the following problem experimentally, taken from a A Primer for the Mathematics of Financial Engineering. Problem: Let X be the number of times you must flip a fair coin until it lands heads. What are E[X] (expected…
Josmoor98
  • 1,418
  • 5
  • 21
1
vote
2 answers

Coin tossing simulation unexpected probabilities

This is a script I wrote to simulate a coin toss game that ends in a given fixed sequence of outcomes (tosses are either ones or zeroes). This fixed sequence characterizes the game. For example, coin_series('01') simulates a series of tosses that…
Psmith
  • 43
  • 1
  • 6
1
vote
2 answers

Statistics - Standard Deviation of test statistic # of heads - # of tails

I have a question concerning the following N is the no. of coin tosses H is the no. of heads obtained T is the no. of tails obtained Q = H-T N = 100 H = 63 T = 37 Q = 26 Is this significant evidence that the coin is unbiased? what is the standard…
gvdd
  • 27
  • 4
1
vote
2 answers

convert an unfair coin into a fair coin in Python 2.7

Using Python 2.7. Suppose I have an unfair coin and I want to turn it into a fair coin using the following way, Probability of generating head is equal for unfair coin; Flip unfair coin and only accept head; When a head is appearing, treat it as 1…
Lin Ma
  • 8,271
  • 25
  • 84
  • 152
1
vote
1 answer

Flip coin simulation with R programming

I'm new to R and I'm doing a practice question. Simulate rolling a fair coin 200 times, then plot a histogram of the data. I did: outcomes <- c("heads", "tails") sim_fair_coin <- sample(outcomes, size = 200, replace =…
Jim_dddd
  • 163
  • 1
  • 3
  • 11
1
vote
2 answers

Generating Coin flips using purrr

Now I'm learning how to use purrr package in r, and thinking about how to generate 5 samples of each 1, 2, ..., 99, 100 coin flips. My image is to create a list, that should look like.. [[1]] [[1]] [1] 1 0 1 0 0 [[2]] [[1]] [1] 1 0 0 0…
1
vote
1 answer

Coin Toss Plot similar to Feller

From Feller (1950) An Introduction to Probability Theory: A path of length n can be interpreted as the record of an ideal experiment consisting of n successive tosses of a coin. If +1 stands for heads, then Sk equals the (positive or negative)…
Frank Zafka
  • 799
  • 8
  • 29
1
vote
3 answers

python - infinite coin flip that stops when number of heads = number of tails

I'm new to python and I'm trying to create a coinflip loop which will keep flipping and counting the number of flips until the number of heads = the number of tails, where it will stop and print the total number of flips it took to reach that. I'm…
1
vote
2 answers

How flipping a coin and display tails and heads counting?

I am very beginner on Java, still getting passion about. I have been given this exercise: "Write a simulator program that flips a coin: One thousand times then prints out how many time you get tails and how many times you get heads" That is what i…
Fred882401
  • 13
  • 1
  • 1
  • 3
1
vote
2 answers

C++ Calling function inside another function

In my C++ class we've been given an assignment to make a coin toss program that has the random number generator in one function and it is called into another function that runs it twelve(12) times. int cointToss() { return rand()%2; } int…
user3427139
  • 17
  • 2
  • 5
1
vote
3 answers

Java Coin Flip Suggestions

I'm working on a coin flip assignment and I have the majority of it functioning properly (albeit in a less elegant fashion compared to the code I see on here). I'm trying to find a way to tell the user which number appears most in their flips, and…
Zack
  • 591
  • 1
  • 9
  • 22
1
vote
1 answer

Generate a random number using coin flips while guarenteeing termination

The usual method to generate a uniform random number 0..n using coin flips is to build a rng for the smallest power of two greater than n in the obvious way, then whenever this algorithm generates a number larger than n-1, throw that number away and…
owencm
  • 6,909
  • 4
  • 32
  • 52