All Questions
Tagged with probability probability-distribution
79
questions
14
votes
3
answers
15k
views
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 ...
5
votes
1
answer
90
views
How to generate random integer that are random "enough"?
I'm trying to solve the 280th problem in Project Euler, and for this I have written the following simulation;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <...
4
votes
2
answers
6k
views
How to find the probability from a normal probability density function in python?
Basically, I have plotted a normal curve by using the values of mean and standard deviation. The y-axis gives the probability density.
How do I find the probability at a certain value "x" on the x-...
4
votes
1
answer
2k
views
How to calibrate the thresholds of neural network output layer in multiclass classification task?
Assume we have a multi-class classification task with 3 classes:
{Cheesecake, Ice Cream, Apple Pie}
Given that we have a trained neural network that can classify which of the three desserts a random ...
3
votes
3
answers
141
views
rbinom; How to ensure at least one "success" is returned?
Is there a way to ensure rbinom() returns at least one success?
I am running rbinom() with a really low probability:
rbinom(5015, size=2, prob= 1/5000))
Since it is a probability distribution, there ...
3
votes
1
answer
196
views
How to decompose efficiently dpoibin into its summands in R?
The Poisson-Binomial distribution concerns the probability of the number of successes in a sequence of independent Bernoulli trials with different probabilities of success. This is a generalization of ...
2
votes
2
answers
138
views
Fastest way to count the number of times each face of a N-sided dice appears for M rolls
Given M rolls of an N sided dice I want to generate an N array which stores the count for the number of times each face of the dice appears.
For example, for a 6 sided dice, for 10 rolls you might get:...
2
votes
2
answers
498
views
How to find cumulative probability for a given value in a GEV distribution in R?
I have fitted my data to a GEV distribution, and I wonder how to find the probability of P(x<=40). Thanks for any help.
library(extRemes)
ams <- c(44.5,43.2,38.1,39.1,32.3,25.4,33.0,32.5,48.5,...
2
votes
2
answers
723
views
Write a random number generator that, based on uniformly distributed numbers between 0 and 1, samples from a Lévy-distribution?
I'm completely new to Python. Could someone show me how can I write a random number generator which samples from the Levy Distribution? I've written the function for the distribution, but I'm confused ...
2
votes
2
answers
452
views
Obtain the value of the random variable given the cumulative probability (Python)
Here is a quick background information. I am trying to obtain a combined CDF for the linear combination of two lognormal random variables using Monte-Carlo approach and then, invert it to do sampling. ...
2
votes
0
answers
116
views
Function that can create any type of probability distribution function
I would like to receive the distribution name and parameters from the user as input and generate a probability distribution from which I can choose a random number proportional to their probability. I ...
2
votes
1
answer
569
views
Matlab: Truncated multivariate normal random sampling?
I am wishing to sample from a truncated multivariate normal distribution directly in Matlab.
I am aware I can simply use mvnrnd and check whether the returned value is within the domain of interest....
2
votes
0
answers
258
views
Plot joint return period
I have two variables var1 and var2. I want to have joint return period plot of two variables like
The blue line indicates the joint return period of two variables and the number indicate the return ...
1
vote
3
answers
203
views
Multiple mutually exclusive events and probabilities in netlogo
consider the following 5 events that can occur in netlogo,
[a b c d e f]
Each event has a specific probability of occurring.
Say [0 0 0.3 0.5 0.1 0.1],
that is, p(a) = 0, p(b) = 0, p (d) = 0.5
One (...
1
vote
1
answer
627
views
Generate probability distribution or smoothing plot from points containing probabilities
I have points which include the probability on the y-axis and values on the x-axis, like:
p1 =
[[0.0, 0.0001430560406790707],
[10.0, 6.2797052001508247e-13],
[15.0, 4.8114669550502021e-06],
[20.0, 0....
1
vote
2
answers
630
views
PDF and CDF for Biased die using Matlab with Central Limit Theorem
I am trying to plot the PDF and CDF for a biased die roll for 10^4 samples using Central Limit Theorem.(CLT)
The die is biased or unfair where even sides are twice as likely as odd sides. Here is the ...
1
vote
2
answers
492
views
Difference between scipy.stats.binom and np.random.binomial
I am learning about probability distribution with python and I'm currently looking at binomial distribution and have seen both the scipy way and numpy method, what I'm trying to understand is that why ...
1
vote
1
answer
118
views
How to get this probability outcome in R?
New to R. Not sure how to go about this problem. Essentially I want to create a Monte Carlo simulation. However this is how it's supposed to go:
There are only 3 people (A,B,C) And only come into ...
1
vote
2
answers
1k
views
calculating sum of two triangular random variables (Matlab)
I would like to calculate the sum of two triangular random variables,
P(x1+x2 < y)
Is there a faster way to implement the sum of two triangular random variables in Matlab?
EDIT: It seems ...
1
vote
2
answers
274
views
How can I generate two Weibull Random Vectors with a given correlation coefficient in Matlab?
I need to create two vectors X and Y containing both N samples. They are both weibull distributed with the same λ,k parameters and they are correlated with a correlation coefficient ρ that is neither -...
1
vote
2
answers
882
views
PMF and CDF from a piecewise function in R
Given
p <- function(x) {
if (x == -4) {
0.1
} else if (x == -1) {
0.2
} else if (x == 1) {
0.6
} else if (x == 2) {
0.1
} else {
0
}
}
How would I plot the PMF and ...
1
vote
1
answer
425
views
How to make a function that gives probabilities in a Geometric distribution?
I'm using MATLAB to make a function that returns the probability mass function (PMF) for a Geometric distribution when I enter the values of p, q, and the number of attempts (x) as the inputs.
My ...
1
vote
1
answer
169
views
Unit-testing a probability distribution with conditionals
I have a function choose(elems) -> elem that calls rand() which makes it non-deterministic.
To be able to better test this, I figured that I could split this function in two,
generate_choices(...
1
vote
1
answer
86
views
Poission Distribution considering time left
I want to calculate the remaining probabilities for each result in a football game at n minute.
In this case I have expected goals for home team of 2.69 and away team 1.12 at 70 minute for a current ...
1
vote
2
answers
414
views
How to tune random.choice probability - python -
I made a function that randomly selects one from a list of texts.
def ttc(*arg):
a = random.choice([*arg])
return ''.join(a)
print(ttc("Price", "Condition", "Loan&...
1
vote
1
answer
280
views
how can i shade the rejection region in matlab for f distribution?
i am required to plot an f-distribution for the given degrees of freedom v1 and v2 determined from 4 samples and shade the rejection region for the given alpha(like in the picture below)
rejection ...
1
vote
1
answer
411
views
How to prevent underflow when calculating probabilities with the Naïve Bayes Classifier algorithm?
I'm working on a Naïve Bayes Classifier algorithm for my data-mining course, however I'm having an underflow problem when calculating the probabilities. The particular data set has ~305 attributes, so ...
1
vote
0
answers
44
views
How many random bits does this algoithm use on average (expected value)?
Here, flip() is a function that returns 0 or 1 with equal probability. It can be proved function Random(n) returns a number from 0 to n-1 with identically distributed probabilities (using loop ...
1
vote
1
answer
106
views
KL and JS Divergence analysis of PDFs of numbers
I am playing around with divergence metrics, and I found that if I implement the calculations on my own or rely on the built-in libs, I get two different numbers. Now, I don't know what am (is) I (the ...
1
vote
0
answers
326
views
Measuring the overlap between two probability distribution
I have many probability distributions, I need to compute the amount of overlap between two probability distributions. I don't know the type of distribution since it really depends on the data itself.
...
1
vote
0
answers
3k
views
Total Variation Distance for continuous distributions in Python(or R)
I would like to calculate the total variation distance(TVD) between two continuous probability distributions. I would like to point out that while there are two relevant questions(see here and here), ...
1
vote
0
answers
195
views
Probability distribution of throwing 100 dice using Gaussian/Normal distribution bell curve
I have a program that simulates a fair dice 100 times.
Using this program I need to have a bell curve over the histogram showing normal/Gaussian distribution.
In my code The variable representing ...
1
vote
0
answers
27
views
Kulback Leibler divergence between two vectors of words
I have two vectors of words, for ex:
v1 = ["today", "rainy", "weather", "storm"]
v2 = ["prediction", "sunny", "high", "temperature"]
I would like to compute the Kulback Leibler divergence ...
0
votes
5
answers
500
views
How can I calculate the following probability for two random variables: Pr(Y>X) in R?
How can I find this probability P(X<Y) in R? knowing that X and Y are independent random variables, where X~beta(1,1), Y~beta(2,3)?
0
votes
1
answer
300
views
Uniform sampling arroung a unit sphere
I am looking for an algorithm to uniformly sample the surface of a unit sphere.
I have been reading in https://mathworld.wolfram.com/SpherePointPicking.html.
Their approach appears to translate as:
...
0
votes
2
answers
53
views
How to decide the probability percentage in question
I have the below question:
In the first part of the question, is says the probability that the selected person will be a male is 0.44, it means the number of males is 25*0.44 = 11. That's ok
In the ...
0
votes
3
answers
314
views
Sample Distribution Simulation not resulting in Normal
I was trying to simulate "Sampling Distribution of Sample Proportions" using Python. I tried with a Bernoulli Variable as in example here
The crux is that, out of large number of gumballs, we have ...
0
votes
2
answers
472
views
How to programatically get parameter names and values in scipy
Is there any way to get the parameters of a distribution? I know almost every distribution has "loc" and "scale" but theres differences between them, for example alpha has "a", beta has "a" ,"b".
...
0
votes
1
answer
71
views
Probability distribution of results from one, two and more draws
I am learning python and I found something not intuitive from my perspective. I was trying to print Gausses curve, based on output from lottery. In that program I can set draw range, number of draws ...
0
votes
1
answer
366
views
How do I find if 2 random variables are conditionally independent given the joint conditional PMF?
This is the question, but I can not find a way on how to tackle it...
I know that if they are independent then:
p(X, Y|Z) = p(X|Z)p(Y|Z)
p(X|Y, Z) = p(X|Z)
p(Y|X, Z) = p(Y|Z)
Does someone have some ...
0
votes
1
answer
72
views
Marginalizing a factor on tensorflow probability
I have a joint probability distribution that is defined like this:
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
def model():
s1 = yield tfd....
0
votes
1
answer
165
views
R select element by using probability proportional of the elements [closed]
is there any simple function or package to select element in the vector or list by using elements probability portions? (in R)
my vector is : c(7,5,3,3,2,1,1,1,1)
0
votes
1
answer
51
views
Probability Distribution like x^2
I searched a while and could't find any probability distribution that fits my needs. The Distribution should look something like the function c1 * x^2 + c2. The closest I could find in numpy is the ...
0
votes
2
answers
7k
views
Plotting gamma distribution in R
Am trying to plot a gamma distribution histogram using R
so i have
gam(10, 0.5)
I have previously calculated mean as
10* 0.5 = 5
So Am supposed to plot a histoigram of 100 observations with scale ...
0
votes
1
answer
124
views
Conditional mutual information notations
It might be a naive question but I am really struggling with this. I have looked at number of papers and articles that present the formula of the Mutual information and the Conditional Mutual ...
0
votes
1
answer
120
views
Why does my Monte Carlo simulation not give a normal distribution?
Why does my python Monte Carlo simulation not produce a normal distribution?
import random
import matplotlib.pyplot as pyplot
import numpy
P = 0.1
TR = 1_000
l = []
for _ in range(TR):
tosses = ...
0
votes
0
answers
34
views
Random selection based on weightage and previous history
I have a spring boot application for a notification system. Consider sms notifications for which I have n vendors to select from. Every vendor has been promised a certain percentage of our business, ...
0
votes
1
answer
59
views
How can I use simulation tool in Excel for solving the following problem related to probability?
Trial Number 1 2 3 4 5 ........ 2000000 (two million)
Success in nth attempt 12 4 21 5 10 12
Note: Imagine throwing a dice where each outcome has ...
0
votes
0
answers
68
views
How do I generate numbers according to a parabolic distribution?
I have a function which plots the distribution of ions emitted as a function of the angle of emission. To simulate the emission I would like to sample values according to the function, but I'm ...
0
votes
1
answer
193
views
Binomial Distribution problem using Montee Carlo
Here, I tried to compute probability of getting one 4 times when I toss a die 6 times.
Here is my code,
no=0
import random as rd
for i in range(1000):
l=[rd.randint(1,6) for i in range(6)]
a=l....