Matrix multiplication error in conjugate transpose

1 view (last 30 days)
I get Incorrect dimensions for matrix multiplication error in step 4, line 75 and furthur, what can I do?
%Defining input parameters
function [chp] = dualaccumulatorahk(d,l,N,T,S1,S2,U1,V1,w)
%d is decay and is mostly considered as 1 in this model and would be open to more values in the extended version
%l is Lambda, N is the number of simulations of the deliberative process, T is the time range
%S1 is payoff matrix where self is the row player and S2 is payoff matrix where other is row player
%U1 and V1 are salience biases of players 1 and 2, respectively and in the
%absence of bias will set to 99
% w is trembling hand noise which is 0 here
%example: considering a two-strategy hide-and-seek game with player 1 as a hider and player 2 as a seeker we have:
%0,.5 1,0
%1,0 0,.5 as a full payoff matrix and the aforementioned parameters are:
d = 1;
S1 =[100,60,62,64;60,62,66,70];
S2 =[70,69,66,10;10,40,66,68];
l = 1;
T = 30;
U1 = 99;
V1 = 99;
N = 10000;
w = 0;
% Step 0 & 1
% possible number of strategies per player
ns1 = length(S1(:,1));
ns2 = length(S2(:,1));
chp = zeros(ns1,N)
% set a start for activation biases
if U1 == 99
U1 = zeros(1,ns1);
end
if V1 == 99
V1 = zeros(1,ns2);
end
%initiation of N simulations
for i = 1:N
U = zeros([ns1,T+1]); %as in the first column the time is 0
V = zeros([ns2,T+1]);
%Step 2: Leave initial preference and beliefs at 0
U(:,1) = U1;
V(:,1) = V1;
for t = 2:T+1
%Step 3: Sample one of the opponent's strategies
A = V(:,t-1) + V1';
P = exp(1*A)/sum(exp(1*A));
%See whether the definition of P is legit
if sum(isfinite(P)) < ns2
P = zeros(1,ns2)';
for k = 1:ns2
if A(k)== max(A)
P(k) = 1;
end
end
P = P/sum(P);
end
% Step 4: Update activations in preference node
U(:,t);
d*U(:,t-1);
S1*mnrnd(1,P)';
normrnd(0,w,ns1,1)
U1
U(:,t) = d*U(:,t-1) + S1*(mnrnd(1,P')') + normrnd(0,w,ns1,1);
% Step 5: Sample one of the decision maker’s own strategies
A = U(:,t) + U1';
P = exp(l*A)/sum(exp(l*A));
if sum(isfinite(P)) < ns1
P =zeros(1,ns1)';
for k = 1:ns1
if A(k) == max(A)
P(k) = 1;
end
end
P = P/sum(P);
end
% Step 6: Update activations in belief node
% V(:,t) = d*V(:,t-1) + S2*(mnrnd(1,P')') + normrnd(0,w,ns2,1);
end
% Step 7 & 8: making decision
for k = 1:ns1
if U(k,T+1) == max(U(:,T+1))
chp(k,i) = 1;
end
end
chp(:,i) = chp(:,i)/sum(chp(:,i));
end
% Step 9: Getting the average choice probabilities for each of the decision maker’s strategies
for k = 1:ns1
chp2(k) = mean(chp(k,:));
end
  5 Comments
Amir Hossein K
Amir Hossein K on 23 Apr 2020
Geoff - I tried to write the codes using the following pseudocode and I think the dimensions are correct and even if I ignore the codes above (which are related to activation of preference node), I'll have the same problem in the next line. I also have a problem in defining a range for T which is between 0-30.
Geoff Hayes
Geoff Hayes on 23 Apr 2020
Amir - hopefully someone else will be able to comment on this. It isn't all that clear to me how the above pseudocode translates to your code.

Sign in to comment.

Answers (0)

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!