-
Notifications
You must be signed in to change notification settings - Fork 1
/
Exp3.m
43 lines (22 loc) · 1.3 KB
/
Exp3.m
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
%% Inputs:
% environment: Matrix of size Horizon x NbrArms
% gamma: exploration rate (Default value = 0.05)
%% Outputs:
% gainEXP3: vector of observations for each time step
function gainEXP3 = Exp3(environment, gamma)
[Horizon, NbrArms] = size(environment);
if nargin == 1;
gamma = 0.05; % Exploration Rate
end
%---------------------------------------------------------------------------------------------------
%% INITIALIZATION
%--------------------------------------------------------------------------------------------------
[w, gainEXP3] = EXP3_Initialize(NbrArms); % Initialize the vector weight w
%---------------------------------------------------------------------------------------------------
%% INTERACTION
%--------------------------------------------------------------------------------------------------
for t = 1:Horizon;
[ArmToPlay, p] = EXP3_RecommendArm(w, gamma);
reward = rand() < environment(t,ArmToPlay);
[w, gainEXP3] = EXP3_ReceiveReward(w, p, reward, NbrArms, gamma, ArmToPlay, gainEXP3);
end