% % Skeleton solution for the stimulus sampling theory solution based on % Estes & Burke. % % You need to change the bits that say INSERT CODE HERE. % Feel free to use as is or start from scratch. % % ---------------------------------------------------------- % % Modeling Behavior % Psychology 891C % Fall 2004 % % Andrew L. Cohen % 9/23/04 % % --------------------------------------------------------- % % First set up some constants -------------------- % The number of elements in sets 1 and 2 N1 = 100; N2 = 100; % The total number of elements N = N1 + N2; % The sampling probabilities for sets 1 and 2 theta1 = .3; theta2 = .1; % The average sampling probability over all sets theta_bar = (theta1 + theta2)/2; % The range of trials to plot nRange = 0:50; % Calculate analytic solution --------------------- k = 1; for n = nRange p_analytical(k) = % INSERT CODE HERE k = k + 1; end % Plot analytic solution plot(nRange, p_analytical); hold on % Calculate simulated solution -------------------- % SX_associated has 1's where the elements from Set X are associated with A % and 0's where the elements are not associated with A. Start off with % nothing associated with A. S1_associated = zeros(1, N1); S2_associated = zeros(1, N2); k = 1; for n = nRange % SX_activated has 1's where the elements from Set X are activated on a % particular trial and 0's where the elements are not activated % (sampled). Remember that this should be independent of past trials. % Check out what rand(1, 10) < .3 does. ones(1, 10) might also be helpful. S1_activated = % INSERT CODE HERE S2_activated = % INSERT CODE HERE % Combines the 2 sets of elements into one vector activated = [S1_activated S2_activated]; associated = [S1_associated S2_associated]; % forA is a 1xN vector that has 1's where items are activated AND % associated with A and 0 otherwise. Hint: check out what .* does to % two vectors of 0's and 1's. forA = % INSERT CODE HERE % Given that we now know which elements are activated and which are % associated with A, determines the probability of an A response. p_simulated(k) = % INSERT CODE HERE % Associates all of the activated elements with A. 1's where they are % associated and 0's where they are not. Hint: check out what | does to % two vectors of 0's and 1's. S1_associated = % INSERT CODE HERE S2_associated = % INSERT CODE HERE k = k + 1; end % Plot simulated solution plot(nRange, p_simulated, 'r--'); hold off