Question: Sampling from a Distribution Let the set N [1,..., n, ..., N] be a set of integers and p be a probability distribution p
Sampling from a Distribution Let the set N [1,..., n, ..., N] be a set of integers and p be a probability distribution p = [p1, ..., pn, ..., PN J such that pk is the probability of observing kEN. Note that since p is a distribution then 1Tp = 1 and 0 s pks 1 vn. Write a function sample(M, p) that returns M indices sampled from the distribution p. Provide evidence that your function is working as desired. Note that all sampling is assumed to be i.i.d. You must include a couple of paragraphs and documented code that discusses how you were able to accomplish this task.
Step by Step Solution
3.43 Rating (162 Votes )
There are 3 Steps involved in it
Here is a function to sample indices from a discrete probability distribution python import random d... View full answer
Get step-by-step solutions from verified subject matter experts
