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

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

2011/2012

Uploaded on 08/12/2012

ranganath
ranganath 🇮🇳

4.7

(3)

37 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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