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.

probability
Filter by
Sorted by
Tagged with
9 votes
3 answers
4k views

How do I add and subtract probability disributions like real numbers?

I'd like your advice: could you recommend a library that allows you to add/subtract/multiply/divide PDFs (Probability Density Functions) like real numbers? Behind the scenes, it would have to do a ...
Contango's user avatar
  • 78.3k
9 votes
1 answer
552 views

Probability computation and algorithm for subsequences

Here is a game where cards 1-50 are distributed to two players each having 10 cards which are in random order. Aim is to sort all the cards and whoever does it first is the winner. Every time a person ...
kumar's user avatar
  • 2,726
8 votes
2 answers
6k views

How do i execute one event in php based on a probability for the event to happen

i want something like this: $chance = 40; //40% if ( run the probability check script ) { echo "event happened"; //do the event } else { echo "event didn't happened"; } what is the best ...
Artur Mendes's user avatar
8 votes
4 answers
5k views

Computing a binomial probability for huge numbers

I want to compute binomial probabilities on python. I tried to apply the formula: probability = scipy.misc.comb(n,k)*(p**k)*((1-p)**(n-k)) Some of the probabilities I get are infinite. I checked ...
bigTree's user avatar
  • 2,143
8 votes
6 answers
9k views

Random rounding to integer in Python

I am looking for a way to round a floating point number up or down to the next integer based on a probability derived from the numbers after the decimal point. For example the floating number 6.1 can ...
Johannes's user avatar
  • 1,034
8 votes
3 answers
6k views

Returning a random value from array with probability proportional to it's value

I have an array like $keywords = array('apple'=>10,'orange'=>2,'grape'=>12); I want to randomly pick one of the "Key" from the array. However the probability distribution should be such ...
Eastern Monk's user avatar
  • 6,515
8 votes
5 answers
1k views

Probability theory and project planning [closed]

I'm managing a project that has to be estimated, according to rough requirements and specifications. Because of that, the estimations on the specific features and tasks are set of discrete values, ...
Dimitar Dimitrov's user avatar
8 votes
7 answers
15k views

generate random numbers within a range with different probabilities

How can i generate a random number between A = 1 and B = 10 where each number has a different probability? Example: number / probability 1 - 20% 2 - 20% 3 - 10% 4 - 5% 5 - 5% ...and so on. I'...
Dan Dinu's user avatar
  • 33k
8 votes
1 answer
1k views

DistributionFitTest[] for custom distributions in Mathematica

I have PDFs and CDFs for two custom distributions, a means of generating RandomVariates for each, and code for fitting parameters to data. Some of this code I've posted previously at: Calculating ...
Jagra's user avatar
  • 3,149
8 votes
3 answers
10k views

Determining if the difference between two error values is significant

I'm evaluating a number of different algorithms whose job is to predict the probability of an event occurring. I am testing the algorithms on large-ish datasets. I measure their effectiveness using "...
sanity's user avatar
  • 35.5k
8 votes
2 answers
11k views

Generating random numbers with a given probability density function

I want to specify the probability density function of a distribution and then pick up N random numbers from that distribution in Python. How do I go about doing that?
user2445465's user avatar
8 votes
4 answers
7k views

Three colors triangles

I am trying to make a code for this problem: (Source: https://www.codewars.com/kata/insane-coloured-triangles/train/c) A coloured triangle is created from a row of colours, each of which is ...
Holy semicolon's user avatar
8 votes
4 answers
5k views

Discrete Probability Distribution in Java

I have a set of integers each of which has a probability assigned, derived from earlier experiments, e.g.: 0 = 0.5 1 = 0.2 2 = 0.3 Complying with the specifications of a probability distribution, ...
Carsten's user avatar
  • 1,952
8 votes
2 answers
20k views

Expected collisions for perfect 32bit crc

I'm trying to determine how my crc compares to an "ideal" 32bit crc. So I ran my crc over 1 million completely random samples of data and collected the amount of collisions, I want to compare this ...
Tristan's user avatar
  • 3,865
8 votes
2 answers
167 views

What's the term to describe this combination?

There are 4 items: 1, 2, 3, and 4. If we just allow the following combinations, what should we call them? I forgot it. Is it called nCr? 1 2 3 4 1 2 3 1 2 4 2 3 4 1 2 1 3 1 4 2 3 2 4 3 4 1 2 3 4
developer.cyrus's user avatar
8 votes
3 answers
301 views

Way to infer the size of the userbase of a site from sampling taken usernames

Suppose you wanted to estimate the size of a userbase of a site which does not publicize this information. People are more likely to have acquired different usernames with different probabilities. ...
ʞɔıu's user avatar
  • 47.8k
8 votes
1 answer
17k views

Calculating Probability of a Random Variable in a Distribution in Python

Given a mean and standard-deviation defining a normal distribution, how would you calculate the following probabilities in pure-Python (i.e. no Numpy/Scipy or other packages not in the standard ...
Cerin's user avatar
  • 63k
8 votes
3 answers
6k views

Finding stationary distribution of a markov process given a transition probability matrix

There has been two threads related to this issue on Stack Overflow: How can I obtain stationary distribution of a Markov Chain given a transition probability matrix describes what a transition ...
Zheyuan Li's user avatar
  • 72.4k
8 votes
1 answer
8k views

Python - modelling probability

I have a simple problem. I need a way to make a function which generates 0s in p percent cases and 1s in all other cases. I tried doing it with random.random() like this: p = 0.40 def generate(): ...
darxsys's user avatar
  • 1,570
8 votes
1 answer
7k views

Constructing a multi-order Markov chain transition matrix in Matlab

A first-order transition matrix of 6 states can be constructed very elegantly as follows x = [1 6 1 6 4 4 4 3 1 2 2 3 4 5 4 5 2 6 2 6 2 6]; % the Markov chain tm = full(sparse(x(1:end-1),x(2:end),1)...
pangyuteng's user avatar
  • 1,799
8 votes
4 answers
4k views

Rosalind: Mendel's first law

I'm trying to solve the problem at http://rosalind.info/problems/iprb/ Given: Three positive integers k, m, and n, representing a population containing k+m+n organisms: k individuals are ...
user4146164's user avatar
8 votes
1 answer
2k views

Is there any probabilistic data structure that gives false negatives but not false positives?

I need a space efficient probabilistic data structure to store values that I have already computed. For me computation is cheap but space is not - so if this data structure returns a false negative, I ...
pathikrit's user avatar
  • 33.1k
8 votes
3 answers
640 views

re-using random number in reservoir sampling

It was asked in relation to another question recently: Given an unknown length list, return a random item in it by scanning it only 1 time I know you shouldn't, I just can't put my finger on a ...
Will's user avatar
  • 74.8k
8 votes
1 answer
122 views

Function that returns array of array combinations

I'm trying to make a _.combinations function (underscore mixin) that takes three parameters arr, pockets, duplicates. Here's a test that I designed to show how the behavior should be. expect(_....
ThomasReggi's user avatar
  • 57.2k
8 votes
1 answer
1k views

Merkle Tree Data Synchronization False Positives

Merkle trees (aka hash trees) are used for data synchronization in both "Cassandra" & "Dynamo". As with any hash function, there is a probability that different data can have the same hash value: ...
eshalev's user avatar
  • 3,083
8 votes
4 answers
6k views

Calculating pdf of Dirichlet distribution in python

I'd like to calculate the pdf for the Dirichlet distribution in python, but haven't been able to find code to do so in any kind of standard library. scipy.stats includes a long list of distributions ...
jpmccoy's user avatar
  • 115
8 votes
4 answers
6k views

how to numerically sample from a joint, discrete, probability distribution function

I have a 2D "heat map" or PDF that I need to recreate by random sampling. I.E. I have a 2D probability density map showing starting locations. I need to randomly choose starting locations with the ...
gallamine's user avatar
  • 875
8 votes
1 answer
215 views

Probability that a formula fails in IEEE 754

On my computer, I can check that (0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3) evaluates to False. More generally, I can estimate that the formula (a + b) + c == a + (b + c) fails roughly 17% of the time ...
hilberts_drinking_problem's user avatar
8 votes
5 answers
3k views

Histogram matching - image processing - c/c++

I have two histograms. int Hist1[10] = {1,4,3,5,2,5,4,6,3,2}; int Hist1[10] = {1,4,3,15,12,15,4,6,3,2}; Hist1's distribution is of type multi-modal; Hist2's distribution is of type uni-modal with ...
Raj's user avatar
  • 1,113
8 votes
2 answers
4k views

Algorithm for calculating probabilities of a number being drawn opening a book

I have a book with N<10000 pages, and a number x(in the range 1<=x<=40). I want to calculate the probability that, opening that book at random, the combination of the digits of the opened ...
Makers_F's user avatar
  • 3,053
8 votes
0 answers
888 views

Sampling from a joint distribution in Pyro

I understand how to sample from multidimensional categorical, or multivariate normal (with dependence within each column). For example, for a multivariate categorical, this can be done as below: ...
alpaca's user avatar
  • 1,231
8 votes
3 answers
2k views

Using bnlearn Function "cpquery" Within a Loop

I'm attempting to use the bnlearn package to calculate conditional probabilities, and I'm running into a problem when the "cpquery" function is used within a loop. I've created an example, shown below,...
H2O_Research's user avatar
7 votes
6 answers
14k views

Is Pythons random.randint statistically random?

So I'm testing an calculating the probabilities of certain dice rolls, for a game. The base case if that rolling one 10sided die. I did a million samples of this, and ended up with the following ...
Frames Catherine White's user avatar
7 votes
3 answers
9k views

Picking a random item based on probabilities

There's a similar question, I know, but it confused me, so I thought it easier to ask in my way. So I have an array of values, positive and negative. The higher they are, the more probability they ...
FizzBuzz's user avatar
  • 558
7 votes
3 answers
8k views

Choosing n numbers with fixed sum

In some code I want to choose n random numbers in [0,1) which sum to 1. I do so by choosing the numbers independently in [0,1) and normalizing them by dividing each one by the total sum: numbers = [...
Thomas Ahle's user avatar
  • 31.2k
7 votes
3 answers
2k views

Assigning a specific number of values informed by a probability distribution (in R)

Hello and thanks in advance for the help! I am trying to generate a vector with a specific number of values that are assigned according to a probability distribution. For example, I want a vector of ...
Laura's user avatar
  • 689
7 votes
10 answers
11k views

JavaScript - How to randomly sample items without replacement?

JavaScript I've tried searching for something like this, but I am not able to find it. It's a simple idea: a. Take a random number between 0 to 10. b. Let's say the random number rolled is a 3. c....
seRgiOOOOOO's user avatar
7 votes
6 answers
5k views

Ruby: Using rand() in code but writing tests to verify probabilities

I have some code which delivers things based on weighted random. Things with more weight are more likely to be randomly chosen. Now being a good rubyist I of couse want to cover all this code with ...
Alex Wayne's user avatar
  • 183k
7 votes
3 answers
5k views

Python, SimPy: How to generate a value from a triangular probability distribution?

I want to run a simulation that uses as parameter a value generated from a triangular probability distribution with lower limit A, mode B and and upper limit C. How can I generate this value in Python?...
andandandand's user avatar
  • 22.1k
7 votes
4 answers
16k views

How to create a probability by a given percentage?

I'm trying to create a percentage-based probability for a game. E.g. if an item has a 45% chance of a critical hit, that must mean it is 45 of 100 hits would be critical. First, I tried to use a ...
maelstrom's user avatar
7 votes
3 answers
24k views

Calculate moments (mean, variance) of distribution in python

I have two arrays. x is the independent variable, and counts is the number of counts of x occurring, like a histogram. I know I can calculate the mean by defining a function: def mean(x,counts): ...
noob4life's user avatar
  • 415
7 votes
2 answers
1k views

Computing the approximate population of a bloom filter

Given a bloom filter of size N-bits and K hash functions, of which M-bits (where M <= N) of the filter are set. Is it possible to approximate the number of elements inserted into the bloom filter? ...
Xander Tulip's user avatar
  • 1,468
7 votes
3 answers
8k views

How to properly sample truncated distributions?

I am trying to learn how to sample truncated distributions. To begin with I decided to try a simple example I found here example I didn't really understand the division by the CDF, therefore I ...
Alexander Cska's user avatar
7 votes
2 answers
3k views

Probability of the Union of Three or More Sets

Consider the following sets of probabilities (the three events are NOT mutually exclusive): 0.05625 success, 0.94375 failure 0.05625 success, 0.94375 failure 0.05625 success, 0.94375 failure How do ...
landroni's user avatar
  • 2,962
7 votes
2 answers
2k views

Solving inverse problems with PyMC

Suppose we're given a prior on X (e.g. X ~ Gaussian) and a forward operator y = f(x). Suppose further we have observed y by means of an experiment and that this experiment can be repeated indefinitely....
juliohm's user avatar
  • 3,741
7 votes
2 answers
9k views

Generating random integers within range with a probability distribution

I have a problem where I want to generate a set of random integer values between 1 and 5 inclusive using a probability distribution. Poisson and Inverse Gamma are two distributions that show the ...
jmc's user avatar
  • 620
7 votes
2 answers
14k views

Probability notation [closed]

I want to ask you about the notation in probability. I know that P(A | B) = the conditional probability that event A occurs given that event B has occurred already But I cannot find what A,B ...
user1328370's user avatar
7 votes
4 answers
4k views

Python equivalent for MATLAB's normplot?

Is there a python equivalent function similar to normplot from MATLAB? Perhaps in matplotlib? MATLAB syntax: x = normrnd(10,1,25,1); normplot(x) Gives: I have tried using matplotlib & numpy ...
siva's user avatar
  • 2,135
7 votes
5 answers
13k views

Create constrained random numbers?

CLEANED UP TEXT: How can I create m=5 random numbers that add upp to, say n=100. But, the first random number is say, 10 < x1 < 30, the second random nr is 5 < x2 < 20, the third random ...
Orvar Korvar's user avatar
7 votes
2 answers
2k views

Netlogo: Assign variable using probabilities

How to assign a string or integer variable to turtle, using probabilities of the variables in a group/list? For example it is 0.4 probability that one specific variable is used from specific group/...
Nety's user avatar
  • 129

1 2 3
4
5
82