Docsity

MATLAB Script for Generating Uniformly Distributed Random Numbers and Creating Histograms, Exercises of Stochastic Processes

Toggle sidebar
bg1
% 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')
docsity.com

Partial preview of the text

Download MATLAB Script for Generating Uniformly Distributed Random Numbers and Creating Histograms and more Exercises Stochastic Processes in PDF only on Docsity!

% 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')

docsity.com