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 Ne [1, ..., n, ..., N] be a set of integers and p be a probability

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

1 Expert Approved Answer
Step: 1 Unlock

Here is a function to sample indices from a discrete probability distribution python import random d... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!