octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #65178] [octave forge] (statistics) pdist2 BIS


From: Dmitri A. Sergatskov
Subject: [Octave-bug-tracker] [bug #65178] [octave forge] (statistics) pdist2 BIST failures
Date: Wed, 17 Jan 2024 13:01:00 -0500 (EST)

Follow-up Comment #1, bug#65178 (group octave):

What is your octave version? With 9.0.1 it passes for me:

octave:3> pkg load statistics
octave:4> test pdist2 verbose
>>>>>
/home/dima/.local/share/octave/api-v58/packages/statistics-1.6.1/pdist2.m
***** shared x, y, xx
 x = [1, 1, 1; 2, 2, 2; 3, 3, 3];
 y = [0, 0, 0; 1, 2, 3; 0, 2, 4; 4, 7, 1];
 xx = [1 2 3; 4 5 6; 7 8 9; 3 2 1];
***** test
 d = sqrt([3, 5, 11, 45; 12, 2, 8, 30; 27, 5, 11, 21]);
 assert (pdist2 (x, y), d);
***** test
 d = [5.1962, 2.2361, 3.3166, 6.7082; ...
      3.4641, 2.2361, 3.3166, 5.4772];
 i = [3, 1, 1, 1; 2, 3, 3, 2];
 [D, I] = pdist2 (x, y, "euclidean", "largest", 2);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 d = [1.7321, 1.4142, 2.8284, 4.5826; ...
      3.4641, 2.2361, 3.3166, 5.4772];
 i = [1, 2, 2, 3;2, 1, 1, 2];
 [D, I] = pdist2 (x, y, "euclidean", "smallest", 2);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 yy = [1 2 3;5 6 7;9 5 1];
 d = [0, 6.1644, 5.3852; 1.4142, 6.9282, 8.7750; ...
      3.7417, 7.0711, 9.9499; 6.1644, 10.4881, 10.3441];
 i = [2, 4, 4; 3, 2, 2; 1, 3, 3; 4, 1, 1];
 [D, I] = pdist2 (y, yy, "euclidean", "smallest", 4);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 yy = [1 2 3;5 6 7;9 5 1];
 d = [0, 38, 29; 2, 48, 77; 14, 50, 99; 38, 110, 107];
 i = [2, 4, 4; 3, 2, 2; 1, 3, 3; 4, 1, 1];
 [D, I] = pdist2 (y, yy, "squaredeuclidean", "smallest", 4);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 yy = [1 2 3;5 6 7;9 5 1];
 d = [0, 3.3256, 2.7249; 0.7610, 3.3453, 4.4799; ...
      1.8514, 3.3869, 5.0703; 2.5525, 5.0709, 5.1297];
 i = [2, 2, 4; 3, 4, 2; 1, 3, 1; 4, 1, 3];
 [D, I] = pdist2 (y, yy, "seuclidean", "smallest", 4);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 d = [2.1213, 4.2426, 6.3640; 1.2247, 2.4495, 4.4159; ...
      3.2404, 4.8990, 6.8191; 2.7386, 4.2426, 6.1237];
 assert (pdist2 (y, x, "mahalanobis"), d, 1e-4);
***** test
 d = [1.2247, 2.4495, 4.4159; 2.1213, 4.2426, 6.1237];
 i = [2, 2, 2; 1, 4, 4];
 [D, I] = pdist2 (y, x, "mahalanobis", "smallest", 2);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 d = [3.2404, 4.8990, 6.8191; 2.7386, 4.2426, 6.3640];
 i = [3, 3, 3; 4, 1, 1];
 [D, I] = pdist2 (y, x, "mahalanobis", "largest", 2);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 yy = [1 2 3;5 6 7;9 5 1];
 d = [0, 8.4853, 18.0416; 2.4495, 10.0995, 19.4808; ...
      2.4495, 10.6771, 19.7104; 2.4495, 10.6771, 20.4573];
 i = [2, 2, 2; 1, 4, 4; 4, 1, 1; 3, 3, 3];
 [D, I] = pdist2 (y, yy, "mahalanobis", "smallest", 4);
 assert ({D, I}, {d, i}, 1e-4);
***** test
 d = [3, 3, 5, 9; 6, 2, 4, 8; 9, 3, 5, 7];
 assert (pdist2 (x, y, "cityblock"), d);
***** test
 d = [1, 2, 3, 6; 2, 1, 2, 5; 3, 2, 3, 4];
 assert (pdist2 (x, y, "chebychev"), d);
***** test
 d = repmat ([NaN, 0.0742, 0.2254, 0.1472], [3, 1]);
 assert (pdist2 (x, y, "cosine"), d, 1e-4);
***** test
 yy = [1 2 3;5 6 7;9 5 1];
 d = [0, 0, 0.5; 0, 0, 2; 1.5, 1.5, 2; NaN, NaN, NaN];
 i = [2, 2, 4; 3, 3, 2; 4, 4, 3; 1, 1, 1];
 [D, I] = pdist2 (y, yy, "correlation", "smallest", 4);
 assert ({D, I}, {d, i}, eps);
 [D, I] = pdist2 (y, yy, "spearman", "smallest", 4);
 assert ({D, I}, {d, i}, eps);
***** test
 d = [1, 2/3, 1, 1; 1, 2/3, 1, 1; 1, 2/3, 2/3, 2/3];
 i = [1, 1, 1, 2; 2, 2, 3, 3; 3, 3, 2, 1];
 [D, I] = pdist2 (x, y, "hamming", "largest", 4);
 assert ({D, I}, {d, i}, eps);
 [D, I] = pdist2 (x, y, "jaccard", "largest", 4);
 assert ({D, I}, {d, i}, eps);
***** test
 xx = [1, 2, 3, 4; 2, 3, 4, 5; 3, 4, 5, 6];
 yy = [1, 2, 2, 3; 2, 3, 3, 4];
 [D, I] = pdist2 (x, y, "euclidean", "Smallest", 4);
 eucldist = @(v,m) sqrt(sumsq(repmat(v,rows(m),1)-m,2));
 [d, i] = pdist2 (x, y, eucldist, "Smallest", 4);
 assert ({D, I}, {d, i});
***** warning<pdist2: matrix is close to singular> ...
 pdist2 (xx, xx, "mahalanobis");
***** error<pdist2: too few input arguments.> pdist2 (1)
***** error<pdist2: X and Y must have equal number of columns.> ...
 pdist2 (ones (4, 5), ones (4))
***** error<pdist2: X and Y must be 2 dimensional matrices.> ...
 pdist2 (ones (4, 2, 3), ones (3, 2))
***** error<pdist2: missing value in optional name/value paired arguments.>
...
 pdist2 (ones (3), ones (3), "euclidean", "Largest")
***** error<pdist2: missing value in optional name/value paired arguments.>
...
 pdist2 (ones (3), ones (3), "minkowski", 3, "Largest")
***** error<pdist2: invalid NAME in optional pairs of arguments.> ...
 pdist2 (ones (3), ones (3), "minkowski", 3, "large", 4)
***** error<pdist2: you can only use either Smallest or Largest.> ...
 pdist2 (ones (3), ones (3), "minkowski", 3, "Largest", 4, "smallest", 5)
***** error<pdist2: Smallest or Largest must be specified to compute second
output.> ...
 [d, i] = pdist2(ones (3), ones (3), "minkowski", 3)
***** error<pdist2: DistParameter for standardized euclidean must be a vector
of> ...
 pdist2 (ones (3), ones (3), "seuclidean", 3)
***** error<pdist2: DistParameter for standardized euclidean must be a
nonnegative> ...
 pdist2 (ones (3), ones (3), "seuclidean", [1, -1, 3])
***** error<pdist2: DistParameter for mahalanobis distance must be a
covariance> ...
 pdist2 (ones (3), eye (3), "mahalanobis", eye(2))
***** error<pdist2: covariance matrix for mahalanobis distance must be
symmetric> ...
 pdist2 (ones (3), eye (3), "mahalanobis", ones(3))
***** error<pdist2: DistParameter for minkowski distance must be a positive
scalar.> ...
 pdist2 (ones (3), eye (3), "minkowski", 0)
***** error<pdist2: DistParameter for minkowski distance must be a positive
scalar.> ...
 pdist2 (ones (3), eye (3), "minkowski", -5)
***** error<pdist2: DistParameter for minkowski distance must be a positive
scalar.> ...
 pdist2 (ones (3), eye (3), "minkowski", [1, 2])
***** error<pdist2: invalid function handle for distance metric.> ...
 pdist2 (ones (3), ones (3), @(v,m) sqrt(repmat(v,rows(m),1)-m,2))
***** error<pdist2: custom distance function produces wrong output size.> ...
 pdist2 (ones (3), ones (3), @(v,m)
sqrt(sum(sumsq(repmat(v,rows(m),1)-m,2))))
PASSES 34 out of 34 tests
octave:5> d = [1.2247, 2.4495, 4.4159; 2.1213, 4.2426, 6.1237];
octave:6> i = [2, 2, 2; 1, 4, 4];
octave:7> [D, I] = pdist2 (y, x, "mahalanobis", "smallest", 2);
error: 'y' undefined near line 1, column 18
octave:8> x = [ 1   1   1
       2   2   2
       3   3   3 ]
x =

   1   1   1
   2   2   2
   3   3   3

octave:9> y = [0   0   0
       1   2   3
       0   2   4
       4   7   1
]
y =

   0   0   0
   1   2   3
   0   2   4
   4   7   1

octave:10> [D, I] = pdist2 (y, x, "mahalanobis", "smallest", 2);
octave:11> I
I =

   2   2   2
   1   4   4

octave:12> i
i =

   2   2   2
   1   4   4



Dmitri.
-- 



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65178>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]