classdef bandit
    %BANDIT simulates a multi-armed bandit with binary reward
    
    properties
        probs                               % probability of each arm
        N                                   % number of arms
    end
    
    methods
        function self = bandit(probs)       % initialize object
            if nargin < 1                   % if no user input
                self.probs = [.28 .32 .26]; % use default
                self.N = 3;                 % use default
            else                            % otherwise
                self.probs = probs;         % use user input
                self.N = length(probs);     % use user input
            end
        end
        
        function reward =  test(self,arm)   % calculate the reward
            reward = rand < self.probs(arm);% reward is 1 or 0
        end
    end
    
end

