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
590
votes
15 answers

Cosmic Rays: what is the probability they will affect a program?

Once again I was in a design review, and encountered the claim that the probability of a particular scenario was "less than the risk of cosmic rays" affecting the program, and it occurred to me that I didn't have the faintest idea what that…
Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
471
votes
16 answers

Find the similarity metric between two strings

How do I get the probability of a string being similar to another string in Python? I want to get a decimal value like 0.9 (meaning 90%) etc. Preferably with standard Python and library. e.g. similar("Apple","Appel") #would have a high…
tenstar
  • 9,816
  • 9
  • 24
  • 45
298
votes
23 answers

Generate a random point within a circle (uniformly)

I need to generate a uniformly random point within a circle of radius R. I realize that by just picking a uniformly random angle in the interval [0 ... 2π), and uniformly random radius in the interval (0 ... R) I would end up with more points…
aioobe
  • 413,195
  • 112
  • 811
  • 826
238
votes
1 answer

Minimizing NExpectation for a custom distribution in Mathematica

This relates to an earlier question from back in June: Calculating expectation for a custom distribution in Mathematica I have a custom mixed distribution defined using a second custom distribution following along the lines discussed by @Sasha in a…
Jagra
  • 3,149
  • 1
  • 18
  • 19
190
votes
9 answers

Why is XOR the default way to combine hashes?

Say you have two hashes H(A) and H(B) and you want to combine them. I've read that a good way to combine two hashes is to XOR them, e.g. XOR( H(A), H(B) ). The best explanation I've found is touched briefly here on these hash function…
Nate Murray
  • 3,841
  • 5
  • 32
  • 33
146
votes
4 answers

Data structures for loaded dice?

Suppose that I have an n-sided loaded die, where each side k has some probability pk of coming up when I roll it. I’m curious if there is a good data structure for storing this information statically (i.e., for a fixed set of probabilities), so that…
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
139
votes
3 answers

Why does this random value have a 25/75 distribution instead of 50/50?

Edit: So basically what I'm trying to write is a 1 bit hash for double. I want to map a double to true or false with a 50/50 chance. For that I wrote code that picks some random numbers (just as an example, I want to use this on data with…
gvlasov
  • 18,638
  • 21
  • 74
  • 110
136
votes
7 answers

Is it safe to assume a GUID will always be unique?

I know there is a minute possibility of a clash but if I generated a batch of 1000 GUIDs (for example), would it be safe to assume they're all unique to save testing each one? Bonus question An optimal way to test a GUID for uniqueness? Bloom filter…
Tom Savage
  • 3,172
  • 4
  • 31
  • 31
122
votes
10 answers

How to calculate probability in a normal distribution given mean & standard deviation?

How to calculate probability in normal distribution given mean, std in Python? I can always explicitly code my own function according to the definition like the OP in this question did: Calculating Probability of a Random Variable in a Distribution…
clwen
  • 20,004
  • 31
  • 77
  • 94
77
votes
14 answers

Select k random elements from a list whose elements have weights

Selecting without any weights (equal probabilities) is beautifully described here. I was wondering if there is a way to convert this approach to a weighted one. I am also interested in other approaches as well. Update: Sampling without replacement
nimcap
  • 10,062
  • 15
  • 61
  • 69
75
votes
13 answers

How to pick an item by its probability?

I have a list of items. Each of these items has its own probability. Can anyone suggest an algorithm to pick an item based on its probability?
Ruzanna
  • 9,766
  • 4
  • 18
  • 23
75
votes
3 answers

How do Markov Chain Chatbots work?

I was thinking of creating a chatbot using something like markov chains, but I'm not entirely sure how to get it to work. From what I understand, you create a table from data with a given word and then words which follow. Is it possible to attach…
Jordan
  • 9,014
  • 8
  • 37
  • 47
74
votes
15 answers

What is the probability that the array will remain the same?

This question has been asked in Microsoft interview. Very much curious to know why these people ask so strange questions on probability? Given a rand(N), a random generator which generates random number from 0 to N-1. int A[N]; // An array of size…
Green goblin
  • 9,898
  • 13
  • 71
  • 100
73
votes
3 answers

Probability of SHA1 collisions

Given a set of 100 different strings of equal length, how can you quantify the probability that a SHA1 digest collision for the strings is unlikely... ?
eastafri
  • 2,186
  • 2
  • 23
  • 34
72
votes
10 answers

Multivariate normal density in Python?

Is there any python package that allows the efficient computation of the PDF (probability density function) of a multivariate normal distribution? It doesn't seem to be included in Numpy/Scipy, and surprisingly a Google search didn't turn up any…
Benno
  • 5,288
  • 5
  • 42
  • 60
1
2 3
99 100