How can I employ Monte Carlo simulation?

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)

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

Hi. the value of lambda is 1 and the true values of alpha is (-0.8,0.0,0.8)
So how are we supposed to use them?
I don't know.Maybe I must create data and add them to data
We have absolutely no idea because the description is incomplete. The best I can come up with is this:
B = 10000
T = [10, 20, 40, 80, 160]
for b = 1 : B
for k = 1 : length(T)
numSamples = T(k);
zT = rand(numSamples, 1);
tTT = rand(numSamples, 1);
% Set the "true" values ​​to α0 ∈ {−0.8, 0.0, 0.8} and λ = 1.
alpha0 = [-0.8, 0.0, 0.8];
lambda = 1;
end
end
but I know it's wrong. However I can't improve it until you explain it better.
No, no emai - I'm not a private consultant. Anything should be able to be public here for everyone to benefit from. Besides, I doubt your instructor would think it was okay for you to turn in my answer as your own would he? Most academic places don't allow that. So I gave you a start. I've marked it as homework on the tag on the right side of this page. Basically Monte Carlo all revolves around getting a set of random numbers and running some experiment millions of times to get some kind of distribution. So why don't you read this link, then post your code (not mine) and we'll give you hints on how to correct it.
What is wt? Is that w(t) which is w as a function of t? What is lambda? I don't see it in any of your formulas. Obviously you teacher discussed some things that I don't know about and you have not shared with us. Is lambda what's normally called sigma - the standard deviation of a Gaussian? Have you looked at randn() to get Gaussian distributed numbers?
It is just exercise from internet so I am curious about solving it. Wt is number of dependent variables at time time. Lambda is usually called sigma, as you mentioned. I have tried but MATLAB doesn't allow so maybe I write randn code wrongly.
Also I can use this normrnd function to generate draws from Normal distribution of epsilon at time t.
OK, but still I don't know how. But I can help you with getting randn() or normrnd() to work. How did you call it?
Epsilon at time is is identical independent distribution function N(0,lambda) and I don't know how to generate random draws from Normal distribution of epsilon at time t
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.

Asked:

on 16 May 2020

Commented:

on 1 Jun 2020

Community Treasure Hunt

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

Start Hunting!