-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmatrix.m
50 lines (44 loc) · 1.59 KB
/
tmatrix.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
44
45
46
47
48
49
50
function [ matrix ] = tmatrix( alphasize, ctrlcount, ctrlpwr, exppwr)
%TMATRIX Produces a matrix of transition probs given the parameters
% They are: the size of the alphabet, the number of "control" pairings,
% and the strength of the control and experimental pairings (ex .5, 1)
% make sure the input is valid
if alphasize <= ctrlcount*2
print('!!!: ctrlcount is too large!')
else if alphasize
end
end
matrix = zeros(alphasize); % construct the matrix
for i = 1:ctrlcount % fill the first rows with control pairings
for j = 1:alphasize
if j == i+ctrlcount
matrix(i,j) = ctrlpwr;
else
matrix(i,j) = (1-ctrlpwr)/(alphasize-1);
end
end
end
% the latter part of control pairings have equiprobable successors
for i = (ctrlcount+1):(ctrlcount*2)
for j = 1:alphasize
matrix(i,j) = 1/alphasize;
end
end
% now the first part of the experimental pairings...
expcount = alphasize/2-ctrlcount;
for i = (ctrlcount*2+1):(ctrlcount*2+expcount)
for j = 1:alphasize
if j == i + (ctrlcount*2+expcount)-ctrlcount*2
matrix(i,j) = exppwr;
else
matrix(i,j) = (1-exppwr)/(alphasize-1);
end
end
end
% almost done; the last part of the experimental pairings
for i = (ctrlcount*2+expcount+1):alphasize
for j = 1:alphasize
matrix(i,j) = 1/alphasize;
end
end
end