subject
Mathematics, 08.11.2019 01:31 lovelyheart5337

Generation of pseudo-random normal rvs. generate sample size of l rvs,

each iid n(mu, sigma^2) rvs. histogram these with nbins =25; see myhistc. m under files, or use your own. however, read the next section because an overlay is required.

develop a plot where you overlay the normalized histogram (with area 1) with the theoretical pdf. show the goodness of fit is good using a chi-squared test. you should know this from your earlier stats class. take mu=-6, sigma^2 = 2; try different sample sizes of l = 10^2,10^3,10^4.

since these are generated using randn, the fit will be excellent and the chi-squared will be small.

myhistc. m

function [xknt, outknt, xcenter, xdelta] = myhistc(x, nbins, xend);

%function [xknt, outknt, xcenter, xdelta] = myhistc(x, nbins, xend);

% a histogram with nbins within the range [xend(1), xend(2)]

% xend (1: 2), for edges, beyond xend, data is counted in outknt

flagprint = 1; %change to 1 for printing and plotting

x = x(: ); lx = length(x);

outknt = zeros(2,1); xknt = zeros(nbins,1);

lindx=0; indx=find(x < = xend(1)); lindx=length(indx); if(lindx ~= 0); outknt(1)=lindx; end

x(indx)=[];

lindx=0; indx=find(x > xend(2)); lindx=length(indx); if(lindx ~= 0); outknt(2)=lindx; end

x(indx)=[];

xdelta = (xend(2)-xend(1))/nbins; xbin = xend(1) + [0: nbins]*xdelta;

xcenter = zeros(nbins,1);

% loop over the few bins, not over the many data

for ibin=[1: nbins]; % loop over bins, not data

lindx=0; indx=find( (xbin(ibin)< x)& ( x < =xbin(ibin+1)) ); lindx=length(indx);

xcenter(ibin) = mean([xbin(ibin) xbin(ibin+1)]);

if(lindx~=0); xknt(ibin)=lindx; end%%x(indx)=[]; end

%disp([ibin, xbin(ibin) xbin(ibin+1) xcenter(ibin) xknt(ibin)])

end

if(flagprint==1);

format bank

disp([' binid lowedge upedge center count'])

for ibin=[1: nbins]; % loop over bins, not data

disp([ibin, xbin(ibin) xbin(ibin+1) xcenter(ibin) xknt(ibin)])

end

end

format short e

if(flagprint==1);

plot( xcenter, xknt,'r*-'); grid

end

ansver
Answers: 2

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 15:30, LadyHolmes67
When i add money am i supposed to make it like this 7+12 or 7.00+12.00 because i got 19 dollars for my answer
Answers: 2
image
Mathematics, 21.06.2019 19:50, ghwolf4p0m7x0
The graph shows the distance kerri drives on a trip. what is kerri's speed . a. 25 b.75 c.60 d.50
Answers: 1
image
Mathematics, 21.06.2019 20:30, danizara8
The sum of these consecutive integers is equal to 9 less than 4 times the least of the integer. find the three integers
Answers: 1
image
Mathematics, 21.06.2019 21:30, Yuii
Hannah paid $3.20 for 16 ounces of potato chips. hank paid $3.23 for 17 ounces of potato chips. who paid less per ounces?
Answers: 1
You know the right answer?
Generation of pseudo-random normal rvs. generate sample size of l rvs,

each iid n(mu, si...

Questions in other subjects:

Konu
Mathematics, 18.09.2019 20:40
Konu
English, 18.09.2019 20:40
Konu
Social Studies, 18.09.2019 20:40