Hi I Need Help Writing The Code For This Problem I M Having Trouble Understanding Wh 2739510

Random number generators initally provide uniformlHi, I need help writing the code for this problem – I’m having trouble understanding what this question is asking for. I am familiar with python so please help me with python coding! Thanks!

Random number generators initally provide uniformly distributed random numbers in a interval of unit length, but often we need to sample from other distributions. Suppose that we wish to simulate a random variable n drawn from Pbinom(n, N = 3, p). We can do this by partitioning the unit segment into four bins of width (1 ? p)3, 3p(1 ? p)2, 3p2(1 ? p) and p3, corresponding to n = 0, 1, 2, 3. The width of each bin is thus proportional to the probability of occurrence. To sample from Pbinom(n, N, p) one thus simply draws a uniformly distributed random number and finds the bin index into which that number falls. (a) Write a function binom setup that accepts a value of p and returns a list of locations of the bin edges appropriate for N=5. (b) Write another function binom dist that accepts the list of bin edges as input and returns a single binomially distributed random variable. (c) Write a short piece of wrapper code that first calls binom setup and then generates a list of 100 binomially distributed random variables. Plot a (normalized if possible) histogram of the data, find the sample mean ?x? and variance ?2 and compare to the expected values for large N, ?x? = Np and ?2 = Np(1 ? p). Repeat for 1000 random numbers and comment.

Random number generators initally provide uniformly distributed random numbers in a interval of unit length, but often we need to sample from other distributions. Suppose that we wish to simulate a random variable n drawn from P (n, N 3, p). We can do this by binom partitioning the unit segment into four bins of width (1-p3, 3p(1-p02, 3p (1 -p and ps corresponding to n 0 1, 2, 3. The width of each bin is thus proportional to the probability of occurrence. To sample from P (n, N, p one thus simply draws a uniformly distributed random number and finds the bin index into which that number falls (a) Write a function binom setup that accepts a value of p and returns a list of locations of the bin edges appropriate for NE5 (b) Write another function binom-dist that accepts the list of bin edges as input and returns a single binomially distributed random variable (c) Write a short piece of wrapper code that first calls binom-setup and then generates a list of 100 binomially distributed random variables. Plot a (normalized if possible) histogram of the data, find the sample mean (r) and variance o2 and compare to the expected values for large N, (ar) Np and or Np(1 p). Repeat for 1000 random numbers and comment

Needs help with similar assignment?

We are available 24x7 to deliver the best services and assignment ready within 3-4 hours? Order a custom-written, plagiarism-free paper

Get Answer Over WhatsApp Order Paper Now

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *