# Questions tagged [probability-theory]

Challenges which involve computing probabilities for random variables and stochastic processes.

67 questions
Filter by
Sorted by
Tagged with
12k views

### What an Odd Function

Your task here will be to implement a function1 that forms a permutation on the positive integers (A bijection from the positive integers onto themselves). This means that each positive integer ...
• 96.5k
3k views

### Not Your Routine Bean Machine

Consider this ASCII version of a mechanism similar to a bean machine or plinko/pachinko game: O ^ \ ^ ^ ^ \ \ ^ / ^ U U U U U 1 2 3 4 5 The ...
• 89.3k
3k views

### 1/N probability

Because there are not enough simple code-golf challenges: Create an optionally unnamed program or function that, given (by any means) an integer 1 ≤ N ≤ 10000, outputs your language's True value with ...
• 29.9k
7k views

• 73.8k
2k views

### Sums of 100 Rolls of Two Six Sided Dice

Suppose you have two six-sided dice. Roll the pair 100 times, calculating the sum of each pair. Print out the number of times each sum occurred. If a sum was never rolled, you must include a zero or ...
• 161
585 views

### Who's that probability distribution?

Introduction In this challenge, you are given a list of nonnegative floating point numbers drawn independently from some probability distribution. Your task is to infer that distribution from the ...
• 42.5k
801 views

### Build a program to analyze coin flip sequence choices

In a puzzle in an old book of mine, a game is defined in which two players choose sequences of coin flips that they believe will appear first when a coin is repeatedly flipped. (It was actually odd ...
• 34.7k
1k views

### Weighted coin flip strings

Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed ...
• 193
2k views

### Calculate the probability of getting to the target first (exactly)

Consider the following probability puzzle. We start with a string of bits all set to 0. At each step we choose a bit uniformly and independently at random and flip it. The value your code has to ...
2k views

### Computer: you do the math

This challenge is partly an algorithms challenge, involves some math and is partly simply a fastest code challenge. For some positive integer n, consider a ...
390 views

### Pólya urn flip and roll

Problem statement Pólya is playing about with his urn again and he wants you to help him calculate some probabilities. In this urn experiment Pólya has an urn which initially contains 1 red and 1 blue ...
• 4,001
1k views

### XKCD Bracket Probabilities

Today's XKCD is a sports-tournament style bracket, where the contestants are well-known names, put into groups of possibly confusing names. Give the probability that a given contestant will win the ...
• 71.8k
5k views

### Plot the Gaussian Distribution in 3D

In probability theory, the normal (or Gaussian) distribution is a very common continuous probability distribution. Normal distributions are important in statistics and are often used in the natural ...
• 13.8k
623 views

### Code golf a random orthogonal matrix

An orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors). This means that M^T M = I, where I is the identity matrix ...
867 views

### Uncertainty in the Timeline of a Day

Suppose your alarm wakes you up one morning, but you hit snooze so you can sleep for 8 more minutes. When it rings again you grudgingly get up and take a shower, which you estimate takes 15 to 17 ...
• 89.3k
517 views

### Generalized Birthday Problem

Tonight, my fiancée took me out to dinner to celebrate my birthday. While we were out, I heard Happy Birthday sung to 5 different guests (including myself), in a restaurant full of 50 people. This got ...
441 views

### What's the chance that I'll win a door prize?

My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). ...
• 21.2k
1k views

### Calculate a probability exactly and quickly

[This is a partner question to Calculate a probability exactly ] This task is about writing code to compute a probability exactly and quickly. The output should be a precise probability written as a ...
1k views

### Probability of something happening at least n out of m times

Write a program or function, that given a success probability p, a number n and a number of trials m returns the chance of at least n successes out of m trials. Your answer must be precise to at ...
• 39k
973 views

### Calculate probability of getting half as many heads as coin tosses.

Write a program that, given a small positive even integer from standard input, calculates the probability that flipping that many coins will result in half as many heads. For example, given 2 coins ...
• 693
934 views

### Probabilities - how high can you go?

I previously asked a question for how to compute a probability quickly and accurately. However, evidently it was too easy as a closed form solution was given! Here is a more difficult version. This ...
2k views

### "i" have "i" chance of occuring

Design a random number generator where the i th number has i% chance of occurring for all 0 < i < 14. 0 should have exactly 9% chance of occurring. The seed for the generator should be the ...
• 3,293
1k views

### Calculate a probability exactly

This task is about writing code to compute a probability exactly. The output should be a precise probability written as a fraction in its most reduced form. That is it should never output ...
1k views

### Random factorized numbers

Input The code should take an integer $n$ between 1 and 1000. Output The code should output positive integers with $n$ bits. Accompanying each integer should be its full factorization. Each ...
• 1,812
349 views

### Knockout probabilities

Knockout is a basketball game where players take turns shooting. It is played as a sequence of two-player contests, each of which has the possibility of "knocking out" one of those players. Suppose ...
• 4,472
198 views

### Talent rolls in DSA

Some friends and I have played some DSA (a mainly german tabletop RPG much like D&D). I was wondering what the chance on passing rolls are, so you will have to write some code to calculate it. ...
• 2,625
466 views

### A Suitable Mission

Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final ...
• 636
300 views

### Card pair probability

Given a deck consisting of N copies of cards with integer values [1,M] for a total of N*M cards, compute the probability that a card with the value of 1 is adjacent to a card with the value of 2. ...
• 2,723
356 views

### Implement an API for probability distributions

Introduction In this challenge, your task is to implement a collection of simple functions that together form a usable mini-library for simple probability distributions. To accommodate some of the ...
• 42.5k
358 views

### Golfception arrives

Lets play golf while we golf. Problem: Distance to the hole initially is 700m Each hit to the ball will make it advance to the hole 250-350m, this should be random. Each hit has a 5% probabilities ...
• 193