last day (16 days later) » 

2:53 AM
@user123 can you provide an example result you take? I am actually sure that you get your matrix reciprocal.
 
3:19 AM
@Burak when I run your code, I got matrices that do not satisfy the multiplicative inverse property: For instance,
1.0000 2.4845 1.4793 1.4579 0.8581 0.8080
2.4941 1.0000 1.4822 1.4607 0.8598 0.8095
4.1887 4.1806 1.0000 2.4532 1.4440 1.3596
4.2502 4.2420 2.5258 1.0000 1.4652 1.3796
7.2209 7.2070 4.2913 4.2291 1.0000 2.3438
7.6691 7.6543 4.5576 4.4916 2.6438 1.0000
Actually, I return M{:} to get the results
This matrix is not reciprocal.
This is the code I am using now:
clear; clc
M = cell(1, 100); % preallocate memory
% matrix contains both x & 1/x
% we need a distribution whose multiplication with its inverse is uniform
pd = makedist('Triangular', 'a', 0, 'b', 1, 'c', 1);
for m=1:100 % 100 random matrices
A = zeros(6); % allocate memory
% 5 random numbers for 6x6 transitive random matrix
a = random(pd, 1, 5);
% choose a or 1/a randomly
c = rand(1, 5) < 0.5;
% put these numbers above the diagonal
for i=1:5
if c(i)
A(i, i+1) = a(i);
else
A(i, i+1) = 1 / a(i);
end
 
 
7 hours later…
10:58 AM
@user123 I have no idea why you get such a result. Cany you try the following code:
clear; clc
% 5 random numbers for 6x6 transitive random matrix
a = [2 3 4 5 6];
% put these numbers above the diagonal
for i=1:5
A(i, i+1) = a(i);
end
% complete the transitivity going above
for k=flip(1:4)
for i=1:k
A(i, i-k+6) = A(i, i-k+5) * A(i-k+5, i-k+6);
end
end
% lower triangle is multiplicative inverse of upper triangle
for i=2:6
for j=1:i-1
A(i,j) = 1 / A(j,i);
end
end
% diagonals are 1
for i=1:6
A(i,i) = 1;
It should output:
1.0000 2.0000 6.0000 24.0000 120.0000 720.0000
0.5000 1.0000 3.0000 12.0000 60.0000 360.0000
0.1667 0.3333 1.0000 4.0000 20.0000 120.0000
0.0417 0.0833 0.2500 1.0000 5.0000 30.0000
0.0083 0.0167 0.0500 0.2000 1.0000 6.0000
0.0014 0.0028 0.0083 0.0333 0.1667 1.0000
 
 
4 hours later…
3:24 PM
Yes, this one works fine. I think the code you posted later has something wrong: I mean, for instance, A = A ./ max(A(:)) * 9 * c); % range becomes (0, 9*c)
But it should have been A = A ./ max(A(:)) * 9 * c; % range becomes (0, 9*c)
so, please can you send me your code here again.
Thanks in advance for your time and help
For instance, I don't understand the following:
c = rand(1, 5) < 0.5;
% put these numbers above the diagonal
for i=1:5
if c(i)
A(i, i+1) = a(i);
else
A(i, i+1) = 1 / a(i);
end
end
AND:
c = 1.1; % scale factor
while c > 1 % in order not to fix the upper limit
c = random(pd);

end
A = A ./ max(A(:)) * 9 * c; % range becomes (0, 9*c)
 
 
2 hours later…
5:30 PM
@user123 it is already as what you say A = A ./ max(A(:)) * 9 * c;
c = rand(1, 5) < 0.5; part puts random numbers a above the diagonal either as it is or as 1/a
c = 1.1; % scale factor part makes max(A(:)) not 9 but 9*(a random number)
Because max(max(A ./ max(A(:)))) = 1
 
 
6 hours later…
11:35 PM
I was wondering if you could send me the whole matlab code (the corrected one that gave you nice result). Because the code that you posted already has an error, and I couldn't fix it yet (in terms of uniform distribution). Thanks again.
I mean, the original code (in the forum).
that appears in the main discussion.
 

  last day (16 days later) »