Physics307L:People/Mondragon/Poisson/Notebook/20071227

From OpenWetWare

Jump to: navigation, search
# number of trials = numtrails
# parameter lambda = lambda

sample=poisson_rnd(lambda,50,numtrials);
maxbin = max(max(sample));
minbin = min(min(sample));
fudge = minbin;
bins=0:maxbins+fudge;
for i=1:50
    histsample(i,:) = hist(sample(i,:),bins);
end

Running bar(bins,histsample(1,:)) would plot a histogram bar graph of the "data" collected in the first "trial." [histx, histy] = bar(bins,histsample(1,:)) generates vectors histx and histy so that plot(histx,histy) results in the same plot as bar(bins,histsample(1,:)). Having vectors histx and histy on hand might prove useful later.

for i=1:50
    [histx(i,:), histy(i,:)] = bar(bins,histsample(i,:))
end
Personal tools