Linked Questions

35 votes
7 answers
35k views

How to generate numbers based on an arbitrary discrete distribution?

How do I generate numbers based on an arbitrary discrete distribution? For example, I have a set of numbers that I want to generate. Say they are labelled from 1-3 as follows. 1: 4%, 2: 50%, 3: 46% ...
user avatar
3 votes
1 answer
772 views

Inverse sampling for discrete data [duplicate]

I have to pick a ball from a set of balls. Each ball has a size, so I have a distribution for ball sizes (I assume a number between 0-1). I want to pick a new ball at each step with the probability ...
user avatar
  • 33
3 votes
2 answers
299 views

Simulating random variables from a discrete distribution II [duplicate]

I have the following discrete probability distribution where $p$, $q$ and $r$ are known constants: $P(X=0)=q$, $0<q<1$ $P(X=1)=1-p-q-r$, $0<p+q+r<1$ $P(X=2)=p$, $0<p<1$ $P(X=3)=...
user avatar
0 votes
0 answers
257 views

How to sample from a joint probability distribution of two variables? [duplicate]

I want to randomly sample from a joint probability distribution characterized by two variables x and y. So, basically, I have the information of the joint PDF which has the dimension 100x50. As per my ...
user avatar
  • 1
0 votes
1 answer
94 views

Randomly generating integers with prior probabilities [duplicate]

I'm after a nice method to draw from a range of integers given known prior probabilities. Say I wanted an 80% chance of drawing 1, a 15% chance of drawing 2, and a 5% chance of drawing 3... I'm ...
user avatar
  • 79
0 votes
0 answers
77 views

How can you model a finite mixture model where it is over a dirac point mass? [duplicate]

I am trying to model the finite mixture model case where: $$ \theta \sim \sum_{h=1}^{k}\pi_h \delta_{\theta^{*}_h} $$ where $\theta^{*}_h \sim Gamma(\alpha, \beta)$, $(\pi_1, \ldots ,\pi_k) \sim ...
user avatar
  • 1,697
4 votes
2 answers
2k views

Sampling from a piecewise linear probability density function

I have a pdf modelled as a piecewise linear function that I can represent as the sequence of pairs of real numbers standing for the points in the of the piecewise line: $\{(x_{1}, y_{1}), \dots, (x_{n}...
user avatar
  • 421
5 votes
2 answers
3k views

Algorithm for generating hyperexponential distribution

I need to generate a hyperexponential distribution for my project. I have already implemented a poisson generating algorithm given by Donald Knuth, but I couldn't find an algorithm for generating a ...
user avatar
2 votes
2 answers
1k views

Generate random number from a specific probability mass in R

How can I generate sample from a distribution with probability mass $P(X=x)$ in R? I know that probability mass, but it is not from a known distribution, also it is not linear, instead it has a ...
user avatar
  • 99
3 votes
1 answer
2k views

How to understand the alias method for generating discrete random variables?

I'm looking to prove the lemma written in chapter 11, page 274 of Sheldon M. Ross's Simulation, regarding the alias method for random variable generation. As a prelude to presenting the method for ...
user avatar
1 vote
1 answer
2k views

Generate bivariate random numbers from joint distribution function

I have an empirical joint distribution function $ \hat{F}(x_1,x_2) = Pr(X_1 < x_1, X_2 < x_2) $ Can I generate bivariate random number from this distribution with a certain condition such as $...
user avatar
  • 931
1 vote
1 answer
674 views

How to sample from "biased" binomial distribution (ideally in python/numpy)

I need to sample a variable from a distribution that's like a binomial distribution except with a "bias", I'm not sure what it may be called: $p(X=k)$ is proportional to $k.B(n,p)(k)$ where $B(n,p)$ ...
user avatar
  • 83
2 votes
1 answer
118 views

How to sample a set of numbers, given the discrete probability distribution for the nth largest number

I recently saw a problem stated like this.. Generate a random set of 3 numbers, each distinct, such that The smallest number has the following pdf: {1: 25%, 2: 30%, 3: 15%, 4: 30%} The 2nd ...
user avatar
  • 1,712
1 vote
1 answer
164 views

Modeling distribution on a dart board

I have statistics for a game similar to lawn dart (3 concentric rings instead of 2) and I wanted to simulate shot distribution. What statistical distribution could I use? The game is throwing a ...
user avatar
  • 37