Please answer all of these questions and show your code. Feel free to use any pr
ID: 3804595 • Letter: P
Question
Please answer all of these questions and show your code. Feel free to use any program to complete all the programs This is a programming assignment. You can use any programming language you like. You have to submit your computer codes along with the homework. l. We will now have a look at computer simulations of continuous random variables. (a) Let X be a continuous random variable that is uniformly distributed on 0,1) lam sure every one of you can determine actual PDF of X. For warmup, we will try to approximate it using numerical data. For this purpose, we can imagine that the rand function in Octave/Matlab/C returns one realization of X As in the previous homework, we call rand n times to get n values, say (1) 0.134,0.456, 0.1938944,0.3928, 0.878, etc. Well, unlike the discrete case, you cannot, for example, take 0.134, and try to count the number of its occurrences in the sequence you generated, as 0.134 will likely happen only once in the entire sequence. This agrees with the fact that P(X a) 0 for any a, when X is a continuous random variable. So, how will you approximate the PDF? The idea is to use a variant of the observation in Page 141 of the book, ie (2) for small o. So, we can pick some small o, and consider the intervals 1-6,1 (3) for some random variable that we know is distributed on C0,1), According to (2), we have P (X e (0, 1) (4) (5) and so on. Now, in order to calculate fx (f), I need P(XEL0,51). This I can estimate from the sequence of n numbers generated. Specifically, POXEl0,o) would approximately be the number of samples that lie in the interval [0 over the total number of samples, n. In this manner, you can approximate all the terms fx (H), fx (1-0. Joining the points (7)
Explanation / Answer
% Generate random data from a uniform distribution
% and calculate the mean. Plot the data and the mean.
n = 50; % 50 data points
r = rand(n,1);
plot(r)
% Draw a line from (0,m) to (n,m)
m = mean(r);
hold on
plot([0,n],[m,m])
hold off
title('Mean of Random Uniform Data')
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.