Last active
November 20, 2015 21:02
-
-
Save jtilly/56d434a40bea208fa640 to your computer and use it in GitHub Desktop.
Emax Type I Extreme Value / Generalized Extreme Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Mean utilities | |
mu1 = 2; | |
mu2 = 3; | |
mu3 = 1; | |
% Scale parameter | |
sigma = 0.4; | |
% Draw Type I extreme value errors | |
R = -evrnd(0,1,100000,3); | |
% Add mean utilities to errors | |
R(:,1) = sigma*R(:,1)+mu1; | |
R(:,2) = sigma*R(:,2)+mu2; | |
R(:,3) = sigma*R(:,3)+mu3; | |
% Compute the unconditional means | |
mean(R,1) | |
[mu1, mu2, mu3] + 0.577*sigma | |
% Compute the unconditional st. deviations | |
std(R,1) | |
sqrt(sigma^2*pi^2/6) | |
% Compute the Emax numerically | |
mean(max(R,[],2)) | |
% Compute the Emax analytically | |
sigma*0.577 + sigma*log(exp(mu1/sigma) + exp(mu2/sigma) + exp(mu3/sigma)) | |
% Let's make this numerically safe | |
mu1 + sigma*0.577 + sigma*log(1 + exp((mu2-mu1)/sigma) + exp((mu3-mu1)/sigma)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment