Questions tagged [probability]

Consider if your question would be better at stats.stackexchange.com. Probability touches upon uncertainty, random phenomena, random numbers, random variables, probability distributions, sampling, combinatorics.

See also https://statistics.stackexchange.com

Probability theory is a branch of mathematics that studies uncertainty and random phenomena. It operates by introducing a sample space (a set), and associating probabilities (numbers between 0 and 1, inclusive) to certain subsets of this set, in a manner that satisfies some sensible axioms. If the sample space can be thought of as the real line, we obtain random variables; if it is a Euclidean space, we obtain random vectors. Random variables and random vectors have associated probability distributions, which can be characterized by probability density functions, cumulative density functions, moments, characteristic or moment generating functions.

Typically, questions with this tag will deal with computing (exactly or approximately) probabilities of certain events (from winning a lottery to server outages), drawing random samples, approximating distributions, etc. There might be an overlap with statistics and/or statistical packages (R, SAS, Stata).

Synonym: probability-theory

4021 questions
22
votes
1 answer

How to simulate bimodal distribution?

I have the following code to generate bimodal distribution but when I graph the histogram. I don't see the 2 modes. I am wondering if there's something wrong with my code. mu1 <- log(1) mu2 <- log(10) sig1 <- log(3) sig2 <- log(3) cpct <- 0.4 …
Amateur
  • 1,247
  • 6
  • 20
  • 30
21
votes
9 answers

Optimal Algorithm for Winning Hangman

In the game Hangman, is it the case that a greedy letter-frequency algorithm is equivalent to a best-chance-of-winning algorithm? Is there ever a case where it's worth sacrificing preservation of your remaining lives, for the sake of a better chance…
Ronald
  • 325
  • 1
  • 2
  • 9
21
votes
12 answers

Probability distribution in Python

I have a bunch of keys that each have an unlikeliness variable. I want to randomly choose one of these keys, yet I want it to be more unlikely for unlikely (key, values) to be chosen than a less unlikely (a more likely) object. I am wondering if you…
Nicholas Leonard
  • 2,566
  • 4
  • 28
  • 32
21
votes
5 answers

permutation & combinations interview

This is a good one because it's so counter-intuitive: Imagine an urn filled with balls, two-thirds of which are of one color and one-third of which are of another. One individual has drawn 5 balls from the urn and found that 4 are red and 1 is…
ʞɔıu
  • 47,148
  • 35
  • 106
  • 149
21
votes
3 answers

How to compute the probability of a value given a list of samples from a distribution in Python?

Not sure if this belongs in statistics, but I am trying to use Python to achieve this. I essentially just have a list of integers: data = [300,244,543,1011,300,125,300 ... ] And I would like to know the probability of a value occurring given this…
qazplok11
  • 427
  • 1
  • 4
  • 13
20
votes
7 answers

Unbiased random number generator using a biased one

You have a biased random number generator that produces a 1 with a probability p and 0 with a probability (1-p). You do not know the value of p. Using this make an unbiased random number generator which produces 1 with a probability 0.5 and 0 with a…
Rohit Banga
  • 18,458
  • 31
  • 113
  • 191
19
votes
6 answers

What is the probability of guessing (matching) a Guid?

Just curious but what is the probability of matching a Guid? Say a Guid from SQL server: 5AC7E650-CFC3-4534-803C-E7E5BBE29B3D is it a factorial?: (36*32)! = (1152)! discuss =D
RhinoDevX64
  • 687
  • 1
  • 5
  • 13
19
votes
4 answers

Calculate the number of ways to roll a certain number

I'm a high school Computer Science student, and today I was given a problem to: Program Description: There is a belief among dice players that in throwing three dice a ten is easier to get than a nine. Can you write a program that proves or…
scrblnrd3
  • 7,228
  • 9
  • 33
  • 64
18
votes
3 answers

How was there no collision among 50,000 random 7-digit hex strings? (The Birthday Problem)

I've encountered some code that generates a number of UUIDs via UUID.randomUUID(), takes the last 7 digits of each (recent versions of UUID are uniformly distributed in terms of entropy), and uses that as a key to insert rows into a database. I…
Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
18
votes
6 answers

What is the probability of collision with a 6 digit random alphanumeric code?

I'm using the following perl code to generate random alphanumeric strings (uppercase letters and numbers, only) to use as unique identifiers for records in my MySQL database. The database is likely to stay under 1,000,000 rows, but the absolute…
Nick
  • 1,311
  • 2
  • 10
  • 27
18
votes
3 answers

Combining individual probabilities in Naive Bayesian spam filtering

I'm currently trying to generate a spam filter by analyzing a corpus I've amassed. I'm using the wikipedia entry http://en.wikipedia.org/wiki/Bayesian_spam_filtering to develop my classification code. I've implemented code to calculate probability…
Jeremy Giberson
  • 1,063
  • 8
  • 15
18
votes
3 answers

Probability of Outcomes Algorithm

I have a probability problem, which I need to simulate in a reasonable amount of time. In simplified form, I have 30 unfair coins each with a different known probability. I then want to ask things like "what is the probability that exactly 12 will…
Kenny
  • 183
  • 1
  • 4
18
votes
6 answers

Generating N numbers that sum to 1

Given an array of size n I want to generate random probabilities for each index such that Sigma(a[0]..a[n-1])=1 One possible result might be: 0 1 2 3 4 0.15 0.2 0.18 0.22 0.25 Another perfectly legal result can be: 0 1 …
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
18
votes
6 answers

Nth Combination

Is there a direct way of getting the Nth combination of an ordered set of all combinations of nCr? Example: I have four elements: [6, 4, 2, 1]. All the possible combinations by taking three at a time would be: [[6, 4, 2], [6, 4, 1], [6, 2, 1], [4,…
Sami
  • 3,263
  • 3
  • 29
  • 37
18
votes
10 answers

How can I efficiently calculate the binomial cumulative distribution function?

Let's say that I know the probability of a "success" is P. I run the test N times, and I see S successes. The test is akin to tossing an unevenly weighted coin (perhaps heads is a success, tails is a failure). I want to know the approximate…
sanity
  • 35,347
  • 40
  • 135
  • 226