Questions tagged [probability-theory]
Challenges which involve computing probabilities for random variables and stochastic processes.
13
questions
51
votes
30
answers
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 ...
33
votes
49
answers
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 ...
10
votes
20
answers
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 ...
10
votes
5
answers
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 ...
43
votes
10
answers
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 ...
30
votes
8
answers
2k
views
Extreme Whitewater Canoeing
You are paddling a canoe down a fairly fast whitewater river. Suddenly, your paddles explode, and you find yourself in a dangerous situation hurtling down a river rapid without any paddles. Luckily, ...
27
votes
36
answers
8k
views
Pick a random number between 0 and n using a constant source of randomness
Task
Given a positive integer n less than 2^30 specified as input in any way you choose, your code should output a random ...
26
votes
3
answers
677
views
A lean, mean bean machine
A classic example to introduce people to the concept of a discrete probability distribution is the bean machine. This machine has a large amount of marbles fall from a narrow passageway at the top, ...
24
votes
22
answers
2k
views
Frequency Distribution of Mixed Dice Rolls
A follow-up to this challenge
Given a set of mixed dice, output the frequency distribution of rolling all of them and summing the rolled numbers on each die.
For example, consider ...
23
votes
22
answers
2k
views
Frequency Distribution of Multiple Dice Rolls
Given two positive integers a and b, output the frequency distribution of rolling a b-sided ...
10
votes
2
answers
936
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 ...
9
votes
4
answers
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 ...
8
votes
7
answers
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 ...