Mathematics
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

answer
Answers: 2

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 16:00, cupcake122016
The classrooms are trying to raise $1,200.00 for charity. mrs. leblanc's class has raised 50%. mr. patel's class has raised $235.14 ms. warner's class has raised 1/3 as much as mrs. leblanc's class. how much more money is needed to reach the goal of $1,200.00?
Answers: 1
image
Mathematics, 21.06.2019 23:00, JulietteRosso995
Anyone know these questions? i need ,.
Answers: 1
image
Mathematics, 21.06.2019 23:40, malikapooh124
Klmn and pqrs are similar trapezoids. which side of pqrs corresponds to lm
Answers: 1
image
Mathematics, 22.06.2019 00:00, kaitlynnputtere
Which choice names the hypotenuse of triangle xyz? a. segment yx b. segment yz c. segment ab d. segment zx
Answers: 3
Do you know the correct answer?
Generation of pseudo-random normal rvs. generate sample size of l rvs,

each iid n(mu, si...

Questions in other subjects:

Konu
Mathematics, 04.10.2020 02:01