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
12
votes
4 answers

How to update a matrix of probabilities

I am trying to find/figure out a function that can update probabilities. Suppose there are three players and each of them get a fruit out of a basket: ["apple", "orange", "banana"] I store the probabilities of each player having each fruit in a…
Hadus
  • 1,551
  • 11
  • 22
12
votes
10 answers

How do I simulate biased die in python?

I want to simulate N-sided biased die? def roll(N,bias): '''this function rolls N dimensional die with biasing provided''' # do something return result >> N=6 >> bias=( 0.20,0.20,0.15,0.15,0.14,0.16,) >> roll(N,bias) 2
Pratik Deoghare
  • 35,497
  • 30
  • 100
  • 146
12
votes
6 answers

How to choose keys from a python dictionary based on weighted probability?

I have a Python dictionary where keys represent some item and values represent some (normalized) weighting for said item. For example: d = {'a': 0.0625, 'c': 0.625, 'b': 0.3125} # Note that sum([v for k,v in d.iteritems()]) == 1 for all `d` Given…
Joseph
  • 12,678
  • 19
  • 76
  • 115
12
votes
3 answers

Find the probability density of a new data point using "density" function in R

I am trying to find the best PDF of a continuous data that has unknown distribution, using the "density" function in R. Now, given a new data point, I want to find the probability density of this data point based on the kernel density estimator that…
programmingIsFun
  • 1,057
  • 2
  • 11
  • 20
12
votes
4 answers

Chance of winning PHP percent calculation

I have a "battle" system, the attacker has a battle strength of e.g. 100, the defender has a strength of e.g. 75. But I'm stuck now, I can't figure out how to find the winner. I know the attacker has a 25% chance of loosing, but I can't figure the…
Sims
  • 167
  • 1
  • 1
  • 8
12
votes
6 answers

How to generate correlated binary variables

I need to generate a series of N random binary variables with a given correlation function. Let x = {xi} be a series of binary variables (taking the value 0 or 1, i running from 1 to N). The marginal probability is given Pr(xi = 1) = p, and the…
jonalm
  • 935
  • 2
  • 11
  • 21
12
votes
1 answer

Arc4random modulo biased

According to this documentation, arc4random_uniform() is recommended over constructions like arc4random() % upper_bound as it avoids "modulo bias" when the upper bound is not a power of two. How bad is the bias? For example if I generate random…
AJ222
  • 1,114
  • 2
  • 18
  • 40
12
votes
2 answers

How do I draw samples from multivariate gaussian distribution parameterized by precision in matlab

I am wondering how to draw samples in matlab, where I have precision matrix and mean as the input argument. I know mvnrnd is a typical way to do so, but it requires the covariance matrix (i.e inverse of precision)) as the argument. I only have…
Jing
  • 895
  • 6
  • 14
  • 38
12
votes
8 answers

What is O value for naive random selection from finite set?

This question on getting random values from a finite set got me thinking... It's fairly common for people to want to retrieve X unique values from a set of Y values. For example, I may want to deal a hand from a deck of cards. I want 5 cards,…
Beska
  • 12,445
  • 14
  • 77
  • 112
11
votes
7 answers

How to implement Random(a,b) with only Random(0,1)?

Possible Duplicate: how to get uniformed random between a, b by a known uniformed random function RANDOM(0,1) In the book of Introduction to algorithms, there is an excise: Describe an implementation of the procedure Random(a, b) that only makes…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
11
votes
5 answers

Test Probabilistic Functions

I need a function which returns an array in random order. I want to ensure that it is randomish but I have no idea how one would go about writing the tests to ensure that the array really is random. I can run the code a bunch of times and see if I…
stimms
  • 42,945
  • 30
  • 96
  • 149
11
votes
3 answers

Python: How to get the convolution of two continuous distributions?

Let X, Y be 2 random variables, with probability density functions pdf1 and pdf2. Z = X + Y Then the probability density function of Z is given by the convolution of pdf1 and pdf2. Since we can't deal with continuous distributions, we descritize…
Pasindu Tennage
  • 1,480
  • 3
  • 14
  • 31
11
votes
6 answers

How do I generate points that match a histogram?

I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs. When the simulation runs, I would like to be able to produce random values that match…
AShelly
  • 34,686
  • 15
  • 91
  • 152
11
votes
2 answers

Python plotting percentile contour lines of a probability distribution

Given a probability distribution with unknown functional form (example below), I like to plot "percentile-based" contour lines, i.e.,those that correspond to regions with an integral of 10%, 20%, ..., 90% etc. ## example of an "arbitrary"…
neither-nor
  • 1,245
  • 2
  • 17
  • 30
11
votes
5 answers

How to calculate conditional probability of values in dataframe pandas-python?

I want to calculate conditional probabilites of ratings('A','B','C') in ratings column. company model rating type 0 ford mustang A coupe 1 chevy camaro B coupe 2 ford fiesta C sedan 3…
Chandu
  • 2,053
  • 3
  • 25
  • 39