
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
Main topics for this course are Stochastic process, random variables, linear congruent generators, pdfs and cdfs, rejection method, metropolis methods, sampling techniques, random walks and genetic algorithm. This matlab code includes: Exponent, Sampling, Function, Random, Numbers, State, Histogram, Subplot, Initialize, Generator, Interval
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

% Program name; expont.m % Sampling from Exponential Function % random numbers from rand function % in interval [0, 1] N = 10000; Max_bins = 50; rand('state', 0) % initialize the generator to state zero for k = 1:N z(k) = 0.; w(k) = 0.; x = rand; tx = log(x); z(k) = -5.0tx; w(k) = -1.0tx; end n = hist(z,Max_bins); m = hist(w,Max_bins); subplot(2,1,1); bar(n, 'r') subplot(2,1,2); bar(m, 'b') % subplot(2,1,1); plot(z) % subplot(2,1,2); plot(w)