Write a Matlab script to investigate the distribution of n numbers generated by
ID: 3771883 • Letter: W
Question
Write a Matlab script to investigate the distribution of n numbers generated by Matlabs random number generator rand. Test your code for: n = 10^1,10^2, 10^3, 10^4 10^5. Use a (e.g.) 10 bin histogram (Matlab function hist) to visually display the distribution. Include appropriate title, labels, axis limits etc. Can you think of another useful way to visually display the uniformity of the distribution. Print out your code and an exemplary plot(s) for: n = 10^4 NB: Make sure your code Is well commented.Explanation / Answer
1.At n=10. The MATLAB script to investigate the distribution of n numbers generated by Matlabs random number generator rand.
Sample output:
Code to copy:
% Obtain a vector of uniform random numbers(0,1).
x = rand(1,10);
% generate histogram plot.
% get the height of the bars.
[N,X] = hist(x,10);
% Generate the plot using the bar function.
bar(X,N,1,'w')
title('Histogram of Uniform Random numbers')
xlabel('X')
ylabel('Frequency')
At n=100.
Sample output:
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.