Question

USING MATLAB (A) Use the rand command to generate “X” of size [10000 1] and the...

USING MATLAB

(A) Use the rand command to generate “X” of size [10000 1] and the command histogram to plot the probability distribution of “X” along with axis labels and a title that includes the mean and variance for “X”. (B) Use a while loop and the rand command to generate “X1”, also of size [10000 1] but with each element of “X1” being the mean of 2 “samples” generated using rand, i.e. a “sample size” of 2 separate numbers generated using rand that are then averaged. This is repeated until “X1” is of size [10000 1].

% Matlab script to create random vectors and plot probability distribution
% A

% generate X of size [10000 1]
X = rand(10000, 1);
% histogram to plot the probability distribution of "X"
histogram(X);
% specify the X and Y labels
xlabel('X');
ylabel('Y');
% specify the title containing the mean and variance of X
txt = sprintf('Mean: %f Variance: %f',mean(X), var(X));
title(txt);

%B
% create X1 of size [10000 1]
X1 = zeros(10000,1);
i=1; % set i to 1
% loop over X1 vector, generating elements for X1
while(i <= length(X1))
samples = rand(2,1); % generate a sample size of 2 using rand
X1(i) = mean(samples); % set ith element of X1 to average of the samples
i = i + 1;
end

%end of script

Output:

Earn Coins

Coins can be redeemed for fabulous gifts.

Need Online Homework Help?

Most questions answered within 1 hours.

Active Questions
• Statistics Discussion: The accuracy of a forecasting technique is evaluated especially using the MSE (mean squared...
• If the U.S. government manages to close a recessionary gap and achieve potential GDP with fiscal...
• A block with mass 10kg is on a ramp angled at 20 degrees above the horizontal,...
• I have a sample of 31 7thgrade girls who took an IQ test.  I calculated the sample...
• A researcher wishes to estimate the proportion of adults who have​ high-speed Internet access. What size...
• Brick column in the external corridor of a house, with section size of 440 mm X520...