How can I employ Monte Carlo simulation?

5 views (last 30 days)
Ulvu Mustafayev
Ulvu Mustafayev on 16 May 2020
Commented: Rena Berman on 1 Jun 2020
How can I write a MATLAB code that generates B = 10000 i.i.d. realizations of zT and tT for sample sizes T = 10, 20, 40, 80, 160. Set the true values to α0 ∈ {−0.8, 0.0, 0.8} and λ = 1.

Answers (1)

Image Analyst
Image Analyst on 16 May 2020
I'm not sure what "Set the true values ​​to α0 ∈ {−0.8, 0.0, 0.8} and λ = 1" means. What are the "true values" which have values of true/false or 1/0?
For what it's worth, I'm attaching some Monte Carlo simulations.
  10 Comments
Image Analyst
Image Analyst on 17 May 2020
Generate a 1-by-N row vector of normally distributed random numbers. Here's a little demo.
%----------------------------------------------------------------------------
% Draw random numbers from a Guassian distribution.
N = 1000000; % Number of points.
mu = 10; % Mean
sigma = 5; % Standard deviation.
% Draw a million numbers with a mean of mu, and a standard deviation of sigma.
r = sigma * randn(1, N) + mu;
%----------------------------------------------------------------------------
% Show histogram.
histogram(r);
grid on;
fontSize = 20;
xlabel('r Value', 'FontSize', fontSize);
ylabel('Count', 'FontSize', fontSize);
% Verify what we actually got:
rMean = mean(r)
rStdDev = std(r);
caption = sprintf('Histogram. Actual Sample Mean = %f Actual Sample StDev = %f', rMean, rStdDev);
title(caption, 'FontSize', fontSize);
% Maximize figure window
g = gcf;
g.WindowState = 'maximized';

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!