Mohit Malhotra MSF
Problem Set 2
%-1.1-Mean of 1,000,000 normally distributed X variables conditional on X being
positive-x = randn(1000000,1);
y = x(find(x>0);
mean(y)
ans =
0.7978
%-1.2-Problem with code-Code y = 2; i = 1; while (y < 10) z(i) = y^2; y =
Mohit Malhotra MSF
Problem Set 7
Answer 1
load usunemploy
y = unemploy(1:3:end); % shift montly data to qtrly
matdate = matdate(1:3:end);
x = (matdate(1:209)-matdate(1)/365.25;
y = y(1:209);
rdate = matdate(1:209)/365.25;
T = length(y);
0itting a linear
Mohit Malhotra MSF
Problem Set 1
diary on
%-1.1-Sum of Squares counting from 2 to 50 by 2-x = [2:2:50];
sum(x)
ans =
650
%-1.2-Sum of the square roots of all numbers from 1 to 5-
x = [1:5];
sum(sqrt(x)
ans =
8.3823
%-1.3-standard deviation of a set of 100