-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim_float.go
40 lines (32 loc) · 918 Bytes
/
sim_float.go
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
// Copyright 2012 - 2015 The Seriation Authors. All rights reserved. See the LICENSE file.
package ser
// Similarity matrices, float.
import (
"math"
)
// Kendall71S computes similarity matrix using Kendall's 1971 Theorem I.
func Kendall71S(dat Matrix64) Matrix64 {
// Ref.:
return Adj2Sim(dat, "rows")
}
// DegOverlap computes a "degree of overlap" between the rows of a data matrix.
func DegOverlap(dat Matrix64) Matrix64 {
// Ref.: Paleo3 280: 469
// Not tested yet. Looks like 1- ManlyOverlap().
rows := dat.Rows()
s := NewMatrix64(rows, rows)
for i, row := range dat {
for h, _ := range dat {
sum1 := 0.0
sum2 := 0.0
sum3 := 0.0
for j, _ := range row { // columns of "dat"
sum1 += dat[i][j] * dat[i][h]
sum2 += dat[i][j] * dat[i][j]
sum3 += dat[h][j] * dat[h][j]
}
s[i][h] = sum1 / (math.Sqrt(sum2) * math.Sqrt(sum3)) //////////// ??????????????
}
}
return s
}