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

Another question on Mathematics

question
Mathematics, 21.06.2019 14:30
Tanya has $42 to spend at the dolphin island store. tshirts sell for $7 each and a pair of sunglases sells for $6.tanya buys 3 tshirts. how many pairs of sunglases can she buys with the amount of money she has left
Answers: 3
question
Mathematics, 21.06.2019 18:00
Which represents the solution set of the inequality 5x-9 < 21? a. x < 12/5 b. x > 12/5 c. x > 6 d. x < 6
Answers: 2
question
Mathematics, 21.06.2019 21:30
Find the volume of the solid obtained by rotating the region enclosed by the curves y=1x and y=7^-x about the x-axis. (use symbolic notation and fractions where needed.) volume =
Answers: 3
question
Mathematics, 22.06.2019 02:30
Which problem would you use the following proportion to solve for? 24/x=40/100 a. what is 40% of 24? b. what percent is 24 of 40? c. twenty-four is 40% of what number? d. forty percent of 24 is what number?
Answers: 3
You know the right answer?
Generation of pseudo-random normal rvs. generate sample size of l rvs,

each iid n(mu, si...
Questions
question
Mathematics, 20.06.2020 03:57