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
4,062
questions
13
votes
3
answers
18k
views
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: -
...
13
votes
2
answers
13k
views
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 ...
13
votes
2
answers
4k
views
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,...
13
votes
3
answers
1k
views
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:
...
13
votes
2
answers
2k
views
Fisher Yates variation
The classic Fisher Yates looks something like this:
void shuffle1(std::vector<int>& vec)
{
int n = vec.size();
for (int i = n - 1; i > 0; --i)
{
std::swap(vec[i], vec[...
13
votes
1
answer
1k
views
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 ...
12
votes
10
answers
19k
views
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....
12
votes
1
answer
2k
views
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 ...
12
votes
3
answers
13k
views
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 ...
12
votes
7
answers
9k
views
How to implement Random(a,b) with only Random(0,1)? [duplicate]
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 ...
12
votes
8
answers
2k
views
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 ...
12
votes
3
answers
10k
views
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 ...
12
votes
2
answers
16k
views
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 ...
12
votes
4
answers
671
views
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", "...
12
votes
6
answers
4k
views
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 ...
11
votes
3
answers
14k
views
Probability of getting the same value using Math.random
The requirement is to send a unique id to database when user click on submit button. So I am using Javascript Math.random method. I just want to know what are the chances or possibility to get same ...
11
votes
5
answers
25k
views
Which java-library computes the cumulative standard normal distribution function?
For a project I have a specification with formulas, I have to implement. In these formulas a cumulative standard normal distribution function exists, that takes a float and outputs a probability. The ...
11
votes
5
answers
40k
views
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 ...
11
votes
1
answer
52k
views
Distribution plot of an array
I have a numpy array containing float values in [-10..10]. I would like to plot a distribution-graph of the values, like this (here it is done for a binomial random variable) :
For example I would ...
11
votes
2
answers
4k
views
Creating Probability/Frequency Axis Grid (Irregularly Spaced) with Matplotlib
I'm trying to create a frequency curve plot, and I'm having trouble manipulating the axis to get the plot I want.
Here is an example of the desired grid/plot I am trying to create:
Here is what I ...
11
votes
2
answers
12k
views
Compute area under density estimation curve, i.e., probability
I have a density estimate (using density function) for my data learningTime (see figure below), and I need to find probability Pr(learningTime > c), i.e., the the area under density curve from a ...
11
votes
6
answers
3k
views
Adjust items chance to be selected from a list
I have a list of items. When I create the list each item has equal chance to be selected. But as an item is selected its chance goes down while the others chance goes up. If a new item is added ...
11
votes
6
answers
3k
views
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 ...
11
votes
1
answer
12k
views
Probability prediction method of KNeighborsClassifier returns only 0 and 1
Can anyone tell me what's the problem with my code?
Why I can predict probability of iris dataset by using LinearRegression but, KNeighborsClassifier gives me 0 or 1 while it should give me a result ...
11
votes
2
answers
9k
views
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%, ..., ...
11
votes
3
answers
4k
views
Does an open-source poker-related math library exist? [closed]
I would like to develop a poker odds application that can give the probability of various game situations. Since the application will be mostly statistical analysis, I figured I would see if someone ...
11
votes
5
answers
2k
views
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. ...
11
votes
2
answers
5k
views
Uniform distribution from a fractal Perlin noise function in C#
My Perlin noise function (which adds up 6 octaves of 3D simplex at 0.75 persistence) generates a 2D array array of doubles.
These numbers each come out normalized to [-1, 1], with mean at 0. I clamp ...
11
votes
1
answer
343
views
Creating all strongly connected graphs with given in-degree with equal probability
I am looking for a way to sample uniformly from the space of all strongly connected directed graphs (without self-loops) of n nodes and in-degree k=(k_1,...,k_n), 1 <= k_i <= n-1.
Input
n, the ...
10
votes
4
answers
55k
views
Random numbers with different probabilities [duplicate]
I need to randomly determine a yes or no outcome (kind of a coin flip) based on a probability that I can define (.25, .50, .75).
So for example, I want to randomly determine yes or no where yes has a ...
10
votes
4
answers
9k
views
Generate Random Numbers with Probabilistic Distribution
Ok, so here's my problem. We are looking at purchasing a data set from a company to augment our existing data set. For the purposes of this question, let's say that this data set ranks places with ...
10
votes
3
answers
3k
views
Dice odds: Simulating a game of Craps
My brother turns 21 in a couple of weeks and my parents and I are taking him to Las Vegas. For my 21st, I brought $200 to gamble in Vegas and came home with around $450, mostly from playing craps. I ...
10
votes
4
answers
31k
views
Using the gaussian probability density function in C++
First, is this the correct C++ representation of the pdf gaussian function ?
float pdf_gaussian = ( 1 / ( s * sqrt(2*M_PI) ) ) * exp( -0.5 * pow( (x-m)/s, 2.0 ) );
Second, does it make sense of we ...
10
votes
4
answers
12k
views
An algorithm to calculate probability of a sum of the results happening
The algorithm I'm talking about using would allow you to present it with x number of items with each having a range of a to b with the result being y. I would like to have an algorithm which would, ...
10
votes
3
answers
34k
views
Getting Probability Density of Data
I need to analyze some data about internet sessions for a DSL Line. I wanted to have a look at how the session durations are distributed. I figured a simple way to do this would be to begin by making ...
10
votes
6
answers
6k
views
Java double and working with really small values
I have to store the product of several probabilty values that are really low (for example, 1E-80). Using the primitive java double would result in zero because of the underflow. I don't want the value ...
10
votes
3
answers
8k
views
Generate a uniformly random point within an annulus (ring) [duplicate]
Possible Duplicate:
Create random number within an annulus
I would like to obtain a uniformly obtained random point within an annulus, that is, the area that lies inside a circle of radius R1, ...
10
votes
1
answer
4k
views
Are SHA1 hashes distributed uniformly?
I have a string in Python. I calculate the SHA1 hash of that string with hashlib. I convert it to its hexadecimal representation and take the last 16 characters to use as an identifier:
hash_str = "...
10
votes
2
answers
889
views
Bayesian inference
I have an instrument that will either pass or fail a series of three tests. The instrument must pass all three tests to be considered successful. How may I use Bayesian inference to look at the ...
10
votes
1
answer
607
views
Space-efficient probabilistic data structures for number retrieval
Consider we have an algorithm that receives a hypothetically long stream of keys. It then generates a value between 0 and 1 for each key, as we process it, for posterior retrieval. The input set is ...
9
votes
3
answers
5k
views
Random numbers based on a probability
I'm having trouble generating random numbers that do not follow a discrete uniform distribution.
So for example, say I have 5 numbers (to keep it simple), a probability of number k being generated ...
9
votes
2
answers
6k
views
C++ function for picking from a list where each element has a distinct probability
I have an array of structs and one of the fields in the struct is a float. I want to pick one of the structs where the probability of picking it is relative to the value of the float. ie
struct s{
...
9
votes
2
answers
537
views
Student's t-distribution CDF R base documentation
In the context of the Student's t-distribution cumulative distribution function, R Version 4.3.1's ?dt documentation highlights the following result:
However, upon attempting to verify the accuracy ...
9
votes
1
answer
8k
views
Probability of collision with truncated SHA-256 hash
I have a database-driven web application where the primary keys of all data rows are obfuscated as follows: SHA256(content type + primary key + secret), truncated to the first 8 characters. The ...
9
votes
2
answers
8k
views
randomized quicksort: probability of two elements comparison?
I am reading "Probability and Computing" by M.Mitzenmacher and E.Upfal. I am having problems understanding how the probability of comparison of two elements is calculated.
Input: sorted list (y1,y2,.....
9
votes
7
answers
24k
views
Predict function error for probabilities in glmnet?
I am trying to predict probabilities in a dataset using glmnet. My code reads:
bank <- read.table("http://www.stat.columbia.edu/~madigan/W2025/data/BankSortedMissing.TXT",header=TRUE)
bank$rich<...
9
votes
3
answers
2k
views
What is the optimal winning strategy for this modified blackjack game?
Questions
Is there a best value to stay on so that I win the greatest percentage of games possible? If so, what is it?
Edit: Is there an exact probability of winning that can be calculated for a ...
9
votes
1
answer
4k
views
How to generate a random number from specified discrete distribution?
Lets say we have some discrete distribution with finite number of possible results, is it possible to generate a random number from this distribution faster than in O(logn), where n is number possible ...
9
votes
2
answers
990
views
Probability of finding the median with finite space
This is a spin off of this StackOverflow question.
Assume that you have a fixed number k of storage locations, and space for two counters. You will receive n items in random order (all permutations ...
9
votes
1
answer
25k
views
Simple binary logistic regression using MATLAB
I'm working on doing a logistic regression using MATLAB for a simple classification problem. My covariate is one continuous variable ranging between 0 and 1, while my categorical response is a binary ...