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
14
votes
2 answers

Plot probability heatmap/hexbin with different sized bins

This is related to another question: Plot weighted frequency matrix. I have this graphic (produced by the code below in R): #Set the number of bets and number of trials and % lines numbet <- 36 numtri <- 1000 #Fill a matrix where the rows are the…
Frank Zafka
  • 829
  • 9
  • 30
14
votes
4 answers

Divide each each cell of large matrix by sum of its row

I have a site by species matrix. The dimensions are 375 x 360. Each value represents the frequency of a species in samples of that site. I am trying to convert this matrix from frequencies to relative abundances at each site. I've tried a few ways…
Zane.Lazare
  • 155
  • 1
  • 1
  • 4
14
votes
2 answers

Chance of a duplicate hash when using first 8 characters of SHA1

If I have an index of URLs, and ID them by the first 8 characters of a SHA1 hash, what is the probability of two different URLs having identical IDs?
zino
  • 1,222
  • 2
  • 17
  • 47
14
votes
6 answers

Implementation of a simple algorithm (to calculate probability)

I've been asked (as part of homework) to design a Java program that does the following: Basically there are 3 cards: Black coloured on both sides Red coloured on both sides Black on one side, red on the other side Now if I take a card randomly…
James
  • 143
  • 1
  • 6
14
votes
2 answers

Implementation of sequential monte carlo method (particle filters)

I'm interested in the simple algorithm for particles filter given here: http://www.aiqus.com/upfiles/PFAlgo.png It seems very simple but I have no idea on how to do it practically. Any idea on how to implement it (just to better understand how it…
shn
  • 5,116
  • 9
  • 34
  • 62
13
votes
2 answers

Fisher Yates variation

The classic Fisher Yates looks something like this: void shuffle1(std::vector& vec) { int n = vec.size(); for (int i = n - 1; i > 0; --i) { std::swap(vec[i], vec[rand() % (i + 1)]); } } Yesterday, I implemented the…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
13
votes
3 answers

Multiple Output Neural Network

I have built my first neural network in python, and i've been playing around with a few datasets; it's going well so far ! I have a quick question regarding modelling events with multiple outcomes: - Say i wish to train a network to tell me the…
13
votes
3 answers

Plot weighted frequency matrix

This question is related to two different questions I have asked previously: 1) Reproduce frequency matrix plot 2) Add 95% confidence limits to cumulative plot I wish to reproduce this plot in R: I have got this far, using the code beneath the…
Frank Zafka
  • 829
  • 9
  • 30
13
votes
2 answers

How to generate random numbers with predefined probability distribution?

I would like to implement a function in python (using numpy) that takes a mathematical function (for ex. p(x) = e^(-x) like below) as input and generates random numbers, that are distributed according to that mathematical-function's probability…
13
votes
1 answer

How to structure a program to work with minesweeper configurations

EDIT: This was a while ago and I've since got it working, if you'd like to see the code it's included at github.com/LewisGaul/minegaulerQt. I'm trying to write a program to calculate probabilities for the game minesweeper, and have had some…
Siwel
  • 705
  • 10
  • 25
13
votes
6 answers

Probabilty based on quicksort partition

I have come across this question: Let 0<α<.5 be some constant (independent of the input array length n). Recall the Partition subroutine employed by the QuickSort algorithm, as explained in lecture. What is the probability that, with a randomly…
POOJA GUPTA
  • 2,295
  • 7
  • 32
  • 60
13
votes
2 answers

Get true or false with a given probability

I'm trying to write a function in c++ that will return true or false based on a probability given. So, for example if the probability given was 0.634 then, 63.4% of the time the function would return true. I've tried a few different things, and…
user2317084
  • 301
  • 5
  • 15
13
votes
1 answer

multinomial pmf in python scipy/numpy

Is there a built-in function in scipy/numpy for getting the PMF of a Multinomial? I'm not sure if binom generalizes in the correct way, e.g. # Attempt to define multinomial with n = 10, p = [0.1, 0.1, 0.8] rv = scipy.stats.binom(10, [0.1, 0.1,…
user248237
13
votes
2 answers

Algorithms/theory behind predictive autocomplete?

Simple word autocomplete just displays a list of words that match the characters that were already typed. But I would like to order the words in the autocomplete list according to the probability of the words occuring, depending on the words that…
chiborg
  • 26,978
  • 14
  • 97
  • 115
13
votes
3 answers

c# probability and random numbers

I want to trigger an event with a probability of 25% based on a random number generated between 1 and 100 using: int rand = random.Next(1,100); Will the following achieve this? if (rand<=25) { // Some event... } I thought I would use a number…
CdrTomalak
  • 479
  • 1
  • 4
  • 15