File size: 1,442 Bytes
2a8276b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
clear;
clc;
set(groot, 'DefaultAxesLineWidth', 1.5);
set(groot, 'DefaultLineLineWidth', 4);
set(groot, 'DefaultAxesTickLabelInterpreter','latex');
set(groot, 'DefaultLegendInterpreter','latex');
set(groot, 'DefaultAxesFontSize',22);
sigma = 10;
x = nodeunif(100, 0, 1);
V1 = x;
V2 = 0.5*x + 0.5;
chi1 = 0;
chi2 = 0.3;
EV = 1/sigma*log(exp(sigma*(V1 - chi1)) + exp(sigma*(V2 - chi2)));
plot(x, [V1, V2])
figure(1)
set(gcf,'DefaultLineLineWidth', 4);
subplot(1,2,1)
plot(x, [V1 - chi1, V2 - chi2, EV])
set(get(gcf,'CurrentAxes'),'FontSize',22,'LineWidth',2);
set(gca,'ygrid', 'on')
title('Values','Interpreter','Latex','FontSize', 22);
h = legend('max', 'gumbell');
set(h,'Interpreter','latex');
subplot(1,2,2)
plot(x, [V1 - chi1 > V2 - chi2, exp(sigma*(V1 - chi1))./(exp(sigma*(V1 - chi1)) + exp(sigma*(V2 - chi2)))]);
set(get(gcf,'CurrentAxes'),'FontSize',22,'LineWidth',2);
set(gca,'ygrid', 'on')
title('Choice Probability','Interpreter','Latex','FontSize', 22);
h = legend('max', 'gumbell');
set(h,'Interpreter','latex');
return
u1 = rand(50000, 1);
u2 = rand(50000, 1);
gamma = double(eulergamma);
mu = -gamma/sigma;
e1 = chi1 + mu - 1/sigma*log(-log(u1));
e2 = chi2 + mu - 1/sigma*log(-log(u2));
figure(2)
histogram(e1, 100)
P1 = mean(V1 - e1' >= V2 - e2', 2);
figure(3)
plot(x, P1, x, exp(sigma*(V1 - chi1))./(exp(sigma*(V1 - chi1)) + exp(sigma*(V2 - chi2)))) |