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
7 votes
3 answers
2k views

Group detection in data sets

Assume a group of data points, such as one plotted here (this graph isn't specific to my problem, but just used as a suitable example): Inspecting the scatter graph visually, it's fairly obvious the ...
Sami's user avatar
  • 3,263
7 votes
5 answers
2k views

Efficiently summing log quantities

Working in C++, I'd like to find the sum of some quantities, and then take the log of the sum: log(a_1 + a_2 + a_3 + ... + a_n) However, I do not have the quantities themselves, I only have their ...
Mike B's user avatar
  • 175
7 votes
1 answer
4k views

Confidence Interval/Margin of Recall or Precision

If I have a confusion matrix that is based upon a sample set, how do I determine the statistical power (confidence margin/interval) of my recall/precision/etc metrics? I know how to do statistical ...
SriK's user avatar
  • 1,071
7 votes
1 answer
7k views

How can I sample a multivariate log-normal distribution in Python?

Using Python, how can I sample data from a multivariate log-normal distribution? For instance, for a multivariate normal, there are two options. Let's assume we have a 3 x 3 covariance matrix and a 3-...
Mack's user avatar
  • 2,654
7 votes
3 answers
2k views

Monty Hall Program Simulation (C#)

I am trying to simulate the Monty Hall Problem (because I read from the book Think Statistics that a guy in particular was convinced only after seeing a computer simulation) in C#, the programming ...
matt's user avatar
  • 2,957
7 votes
4 answers
4k views

Select x random elements from a weighted list in C# (without replacement)

Update: my problem has been solved, I updated the code source in my question to match with Jason's answer. Note that rikitikitik answer is solving the issue of picking cards from a sample with ...
Gabriel's user avatar
  • 1,622
7 votes
3 answers
5k views

Probability of 3-character string appearing in a randomly generated password

If you have a randomly generated password, consisting of only alphanumeric characters, of length 12, and the comparison is case insensitive (i.e. 'A' == 'a'), what is the probability that one specific ...
Richard Pianka's user avatar
7 votes
1 answer
2k views

Why do the inverse t-distributions for small values differ in Matlab and R?

I would like to evaluate the inverse Student's t-distribution function for small values, e.g., 1e-18, in Matlab. The degrees of freedom is 2. Unfortunately, Matlab returns NaN: tinv(1e-18,2) NaN ...
rozsasarpi's user avatar
  • 1,631
7 votes
2 answers
436 views

Sorting with stochastic comparisions

Given a list where for every pair of elements (A, B) the probabilities P(A > B), P(A < B), and P(A = B) is known, how do you determine the most probable sorted permutation?
Jaho's user avatar
  • 81
7 votes
1 answer
7k views

How to calculate derivative of multivariate normal probability density function

Is there any built in function calculating the value of a gradient of multivariate normal probability density function for a given point? Edit: found this how to evaluate derivative of function in ...
Karusmeister's user avatar
7 votes
2 answers
6k views

Generate a matrix of all possible outcomes for throwing n dice (ignoring order)

In cases where order does matter, it's rather easy to generate the matrix of all possible outcomes. One way for doing this is using expand.grid as shown here. What if it doesn't? If I'm right, the ...
Brani's user avatar
  • 6,614
7 votes
1 answer
2k views

Algorithm for O(1) weighted random selection with removal

I'm looking for a weighted random selection algorithm with similar characteristics to the alias method, except where items are removed after they are selected. For example, I have a bag that produces:...
Matt Bierner's user avatar
  • 61.3k
7 votes
1 answer
13k views

Multinomial regression using multinom function in R

I was thinking about posting my question in Cross-Validated, but decided to come here. I am using the multinom() function from the nnet package to estimate the odds of becoming employed, unemployed, ...
Koba's user avatar
  • 1,534
7 votes
1 answer
2k views

What are the ways of deciding probabilities in hidden markov models?

I am starting to learn hidden markov models and on the wiki page, as well as on github there are alot of examples but most of the probabilities are already there(70% change of rain, 30% chance of ...
Lostsoul's user avatar
  • 25.5k
7 votes
3 answers
10k views

Implement probability distribution function in Java problem

I have a function which is in the form of probability distribution function as below: Although I discover some lib providing function to obtain the result as the above formula would do; but I am ...
Alex Jones's user avatar
7 votes
1 answer
3k views

Probabalistic String Matching in Python

I'm in the process of writing a bot that places bets on the website Betfair using their Python API. I want to place bets on football (soccer) matches when they are in-play. I've coded an XML feed to ...
James's user avatar
  • 4,047
7 votes
2 answers
273 views

How to determine the number of possible combinations of letters that contain a degenerate substring

I've been racking my brain for a couple of days to work out a series or closed-form equation to the following problem: Specifically: given all strings of length N that draws from an alphabet of L ...
James McIninch's user avatar
7 votes
0 answers
4k views

Are there any known incidents of UUIDs colliding? [closed]

Has anyone ever experienced a UUID collision in the wild? Anyone heard or read of one happening? Can you provide any details?
Dan's user avatar
  • 736
6 votes
5 answers
2k views

Simulating sports matches in online game

In an online manager game (like Hattrick), I want to simulate matches between two teams. A team consists of 11 players. Every player has a strength value between 1 and 100. I take these strength ...
caw's user avatar
  • 31.2k
6 votes
9 answers
13k views

Determine Frequency of numbers showing up in dice rolls

For a game I'm trying to determine the frequency that a certain # will show up at a given # of dice being rolled. I know... that question seems odd. Let me try to explain it with real numbers. So, ...
bugfixr's user avatar
  • 8,057
6 votes
1 answer
7k views

std normal cdf, normal cdf, or error function

Can any of these functions, the standard normal cumulative distribution function, the normal cumulative distribution function, or the error function, be reliably calculated with javascript? I'd like ...
user avatar
6 votes
3 answers
345 views

How to approach this algorithm question?

A website has a database of n questions. You click a button and are shown one random question per click. The probability of a particular question showing up at the click event is 1/n. On average, how ...
Lazer's user avatar
  • 92.4k
6 votes
2 answers
14k views

R : function to generate a mixture distribution

I need to generate samples from a mixed distribution 40% samples come from Gaussian(mean=2,sd=8) 20% samples come from Cauchy(location=25,scale=2) 40% samples come from Gaussian(mean = 10, sd=6) ...
Raaj's user avatar
  • 1,200
6 votes
2 answers
29k views

Plotting frequency distributions in python

I have a graph stored in an adjacency list format. I randomly select a bunch of nodes and note the number of neighbors each of them have. I now want to plot the distribution, and the way I do it right ...
Dopey's user avatar
  • 61
6 votes
3 answers
2k views

What exactly happens if you delete an object? (gcc) (When double-delete crashes?)

Please note that I don't want to solve any problem with my question - I was thinking about probabilities of things to happen and thus was wondering about something: What exactly happens if you delete ...
IanH's user avatar
  • 3,998
6 votes
1 answer
2k views

Proper boolean random generator (Bernoulli distribution)

I'd be curious to know if there is a default random boolean generator in the random C++11 library. I've been using a int generator returning 0 or 1 and then converting to bool but I'm trying to ...
Learning is a mess's user avatar
6 votes
1 answer
13k views

Kolmogorov-Smirnov test

I'm using the R function ks.test() to test the Uniform distribution of the R random number generator. I'm using the following code: replicate(100000, ks.test(runif(n),y="punif"). When n is less than ...
Egodym's user avatar
  • 453
6 votes
4 answers
18k views

Python: Selecting numbers with associated probabilities [duplicate]

Possible Duplicates: Random weighted choice Generate random numbers with a given (numerical) distribution I have a list of list which contains a series on numbers and there associated ...
Harpal's user avatar
  • 12.3k
6 votes
2 answers
2k views

Generate stochastic random deviates from a density object with R

I have a density object dd created like this: x1 <- rnorm(1000) x2 <- rnorm(1000, 3, 2) x <- rbind(x1, x2) dd <- density(x) plot(dd) Which produces this very non-Gaussian distribution:...
JD Long's user avatar
  • 60.3k
6 votes
2 answers
1k views

Git hash duplicates

Git allows to retrieve the hash of the commit with commands like: git rev-parse HEAD which gives 33b316c or git rev-parse --short HEAD which gives 33b316cbeeab3d69e79b9fb659414af4e7829a32 I know ...
GA1's user avatar
  • 1,588
6 votes
2 answers
1k views

Select random item from stream in O(1) space

Select an item from a stream at random with uniform probability, using constant space The stream provides the following operations: class Stream: def __init__(self, data): self.data = list(...
Борат Сагдиев's user avatar
6 votes
1 answer
8k views

How can I implement the Kullback-Leibler loss in TensorFlow?

I need to minimize KL loss in tensorflow. I tried this function tf.contrib.distributions.kl(dist_a, dist_b, allow_nan=False, name=None), but I failed. I tried to implement it manually: def ...
Alberto Merciai's user avatar
6 votes
2 answers
3k views

Get random item for array based on different probabilities?

Okay, imagine I'm creating a Pokemon game in JavaScript. I have an object like this... pokemon = { "pikachu": {hp: 100, probability: 0.1}, "squirtle": {hp: 90, probability: 0.2} }; I basically ...
Danny's user avatar
  • 993
6 votes
4 answers
417 views

Forward-leaning random numbers' probability distribution

Say I'm pseudo-randomly picking a number from 1 to 50 every second for 100 seconds, and as time goes on the number picked is more likely to be greater. How could I structure such an algorithm? For ...
werdnanoslen's user avatar
6 votes
3 answers
1k views

Probability density function from a paper, implemented using C++, not working as intended

So i'm implementing a heuristic algorithm, and i've come across this function. I have an array of 1 to n (0 to n-1 on C, w/e). I want to choose a number of elements i'll copy to another array. Given ...
hfingler's user avatar
  • 1,996
6 votes
2 answers
379 views

How to generate normal distributed random numbers in Prolog?

I'm a beginner of Prolog. And I'm wondering how to generate normal distributed random numbers in Prolog. What I know is using the maybe from library(random) one can set up the probabilities. But what ...
Meow's user avatar
  • 330
6 votes
2 answers
4k views

Simulate samples from a joint cumulative distribution function?

I have a joint density function for two independent variables X and Y. And I now want to sample new x,y from this distribution. What I believe I have to do is to find the joint cumulative ...
Groot's user avatar
  • 14.1k
6 votes
2 answers
840 views

C: Random walk (Brownian motion) program does not return expected theoretical value. Why?

This is just an experiment based on section 6-3 in "Feynman Lectures on Physics": In its simplest version, we imagine a “game” in which a “player” starts at the point x=0 and at each “move” is ...
vxs8122's user avatar
  • 834
6 votes
3 answers
2k views

Randomly generate a set of m integers from an array of size n

Full Question is: Write a method to randomly generate a set of m integers from an array of size n. Each element must have equal probability of being chosen` This question is picked from "Crack the ...
studying algorithms's user avatar
6 votes
5 answers
4k views

Efficient Method for Calculating the Probability of a Set of Outcomes?

Let's say I'm playing 10 different games. For each game, I know the probability of winning, the probability of tying, and the probability of losing (each game has different probabilities). From ...
Kenny's user avatar
  • 125
6 votes
2 answers
3k views

Select random row from MySQL (with probability)

I have a MySQL table that has a row called cur_odds which is a percent number with the percent probability that that row will get selected. How do I make a query that will actually select the rows in ...
James Simpson's user avatar
6 votes
3 answers
10k views

Pick random element from list with probability

I Have a list that contains four item (A, B, C, D). Every item has a probability to be chosen. Let's say for example A has 74% of chance to be picked, B 15%, C 7% ,and D 4%. I want to create a ...
Zied CHAARI's user avatar
6 votes
2 answers
2k views

Sampling from a bounded domain zipf distribution

I'd like to sample from "zipf" distribution from a bounded domain. That is, assume that the domain is {1,...,N}, I'd like each element in the domain, i, to be chosen with probability proportional to ...
R B's user avatar
  • 543
6 votes
2 answers
2k views

probability of each terminal node in a directed graph

I have a directed graph G(V,E) and weight w(u,v). In this graph weight w(u,v) represents how many times the node(v) has visited from node(u). for example(See this for a directed graph image): 1 ...
ydrall's user avatar
  • 358
6 votes
2 answers
4k views

Is P(A, B) probability equal to P(A intersection B)?

I have to study some probability fundamentals for implementing a computer vision algorithm. However, I'm confused about the notation and meaning of P(A,B) joint probability and P(A intersection B). ...
birsorubircevap's user avatar
6 votes
5 answers
3k views

C# game of chance

I am new to C#. What I am trying to do I am trying to create a game of chance system here. Basically this is how it is: My question: How do I do to accomplish what I am trying to do?
Jack's user avatar
  • 63
6 votes
2 answers
719 views

Time efficient implementation of generating probability tree and then sorting the results

I have some events, where each of them has a probability to happen, and a weight if they do. I want to create all possible combinations of probabilities of events, with the corresponding weights. In ...
Siana's user avatar
  • 63
6 votes
4 answers
7k views

Implementing probability distribution function in Java

I'm trying to implement a probability distribution function in java where it returns the ith entry in the array with probability: Fi = 6i(n-i) / (n3 - n) where n is the array length i.e. for an ...
user528676's user avatar
6 votes
2 answers
2k views

Designing a random number generator

I am trying to design a random number generator which generates random numbers from 0-11.But I need to design that considering I already have a random number generator which generates random number ...
Nilesh's user avatar
  • 281
6 votes
2 answers
4k views

Select random row with different probability - SQL

I want select random row with different probability column based: ID Type Bike 1 Moto 1 Asus 2 Car 1 Apple 2 John 3 If i do this i will have random probability: select top 1 * ...
oteal's user avatar
  • 614

1
3 4
5
6 7
82