
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This matlab script generates 150,000 uniformly distributed random numbers using the 'rand' function and divides them into 20 bins. The histogram of the data is then plotted to visualize the distribution.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

% Program name; lec3_uniform_dist.m % Program to generate 20 bins % random numbers from rand function max_bins = 40; N = 150000; rand('state', 0) % initialize y = rand(N,1); % put into 20 bins n = hist(y, max_bins); m_n = max(n); upper_n = m_n + 1000; % plots the data as a bar graph bar(n); axis([0 max_bins+1 0 upper_n]) xlabel('Bin Number, #') ylabel('Number of Data Values in Each Bin')