Skip to contents

Formula: <x, y>_a = sum_i clr(x)_i clr(y)_i = (1/D) sum_{i<j} log(x_i/x_j) log(y_i/y_j)

Usage

Compip(x, y)

Arguments

x, y

Strictly positive vectors of parts, the same length.

Value

List with inner, inner_pairwise, cos_angle, D. The two inner products agree; both are returned as a self-check.

References

Aitchison (1986), The Statistical Analysis of Compositional Data, Chapter 4. Verified against the reference implementation in the CRAN package compositions 2.0-9, whose scalar applies the centred log-ratio to both arguments and sums the elementwise product.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Compip(V, V)
#> $inner
#> [1] 3.46335
#> 
#> $inner_pairwise
#> [1] 3.46335
#> 
#> $cos_angle
#> [1] 1
#> 
#> $D
#> [1] 8
#> 
#> $method
#> [1] "Aitchison inner product"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"