I have a sub-task of an assignment about the parametric bootstrap method. The subtask is to, given a students t-distribution with $5$ degrees of freedom, sample $10000$ draws using the fundamental theorem of simulation. The algorithm is:
Then, I should produce a histogram of the simulated data and compare it to the exact pdf for the students t-distribution with $5$ degrees of freedom.
My plot "looks" like it has the same distribution but is seems as though it is not right somehow. I´ve inserted my code below for the algorithm, so feel free to comment if I´ve missed a crucial part or misunderstood something!
I guess the goal is to be able to use the histogram as approximation of the integral, but that doesn´t seem to work out for me.
I´ve tried to add more draws but that doesn´t seem to make the histogram any better at approximating the integral, it just adds more "bars" to the histogram. Is it just a scaling/normalizing problem in my code somehow or is there anything else I´m missing?
% Let X be the support of the tpdf, the support is thoeretically the set of % all real numbers, for for this assignment, we let the support be the % interval [a,b] as the absolute values of the y-values outside this interval gets very small. a = -4; b = 4; % Plots the true tpdf to see where a possible max M is X = linspace(a,b); Y = tpdf(X,5); plot(X,Y) % 0.4 will for as a max for the simulation hold on % max := M <= 0.4 M = 0.4; % Number of draws d = 10000; % Matrix for storing accepted points under the curve acc = NaN(d,1); rng(1) % We now want to sample d draws using the fundamental theorem of simulation for k=1:d u1_star = unifrnd(a,b); f = tpdf(u1_star,5); u2_star = unifrnd(0.0,M); if (u2_star < f) acc(k,1) = u1_star; end end acc; histogram(acc,"Normalization","pdf")