Question: Question 3: Write a demonstration program to sample 10 values from a Bernoulli(0) distribution with 0 = 0.3. Recall that there are only two possible



Question 3: Write a demonstration program to sample 10 values from a Bernoulli(0) distribution with 0 = 0.3. Recall that there are only two possible outcomes, 0 and 1. With probability 0, the outcome is 1, and with probability 1 - 0, the outcome is 0. In other words, p(X = 1) = 0, and p(X = 0) = 1 - 0. In Matlab, you can simulate the Bernoulli distribution using the binomial distribution with N = 1. However, for the purpose of this exercise, please write the code needed to randomly sample Bernoulli distributed values that does not make use of the built-in binomial distribution. Using a seed of 21, verify that the first four observations agree with 1, 1, 0 and 1 respectively. Your MATLAB code could use the following line for the seeding: >> seed=21; rand('state', seed); randn('state',seed); Question 4: In this exercise, we want to generate the random variable x=(x1, x2) from Beta(1, ) by inverse transform method. a) Write down the algorithm for generating x. b) Use MATLAB to construct two sets of N=1000 observations each from Beta (1,4). Set seed =131. Plot histograms of both sets on the same graph and print out the first 5 observations from each set. Observe that the first observations are x1=0.0251 and x2 = 0.0348. C) Find the mean of each set generated.Question 2. Adapt the matlab program above to illustrate the Binomial (N, 0) distribution where N = 10 and 0 = 0.7.Question 1. Adapt the Matlab program in Code 6.2 to illustrate the Beta(a, B) distribution where a = 2 and B = 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
