Movatterモバイル変換


[0]ホーム

URL:


Title:Implements Generic Composite Similarity Measure
Version:0.2.0
Description:Provides implementation of the generic composite similarity measure (GCSM) described in Liu et al. (2020) <doi:10.1016/j.ecoinf.2020.101169>. The implementation is in C++ and uses 'RcppArmadillo'. Additionally, implementations of the structural similarity (SSIM) and the composite similarity measure based on means, standard deviations, and correlation coefficient (CMSC), are included.
License:MIT + file LICENSE
Encoding:UTF-8
RoxygenNote:7.3.3
URL:https://github.com/liuyadong/GCSM
BugReports:https://github.com/liuyadong/GCSM/issues
LinkingTo:Rcpp, RcppArmadillo
Imports:Rcpp
Suggests:testthat
NeedsCompilation:yes
Packaged:2025-10-14 17:11:07 UTC; yadong
Author:Yadong LiuORCID iD [aut, cre]
Maintainer:Yadong Liu <liuyadong828@gmail.com>
Repository:CRAN
Date/Publication:2025-10-14 17:20:02 UTC

Composite similarity between vectors

Description

Compute composite measures, GCSM or CMSC, between two vectors.

Usage

cmsc(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")cmsc_e1(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")cmsc_e2(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")gcsm(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")

Arguments

x

A vector.

y

The other vector.

rescale

Rescale or not before computation.

xmin,xmax,ymin,ymax

Normalization parameters. IfNA, are calculatedfrom the ranges ofx andy, respectively. See Details.

comp

Variable to return. If"si", the composite measure, if"s1","s2" or"s3", the corresponding component.

Details

These functions compute composite measures between vectors. Missing valuesare omitted. Normalization parameters are used to rescalex andy, anddetermine the global minimum (min) and maximum (max). Ifrescale isTRUE,x andy are rescaled to(x-xmin)/(xmax-xmin) and(y-ymin)/(ymax-ymin); and setmin=0,max=1. IfFALSE,min=min(xmin,ymin),max=max(xmax,ymax).

Value

A number.

Examples

x = runif(9)gcsm(x, x)cmsc(x, x)# mean shiftgcsm(x, x - 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)cmsc(x, x - 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)gcsm(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)cmsc(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)## dissimilarityy = 1 - x # y is the perfect antianalog of xgcsm(y, x)gcsm(y, x - 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)gcsm(y, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)# random noisenoise = rnorm(9, mean = 0, sd = 0.2)gcsm(x, x + noise, xmin = 0, xmax = 1, ymin = 0, ymax = 1)cmsc(x, x + noise, xmin = 0, xmax = 1, ymin = 0, ymax = 1)## dissimilaritygcsm(y, x + noise, xmin = 0, xmax = 1, ymin = 0, ymax = 1)

Composite similarity on spatial windows

Description

Compute composite measures, GCSM, CMSC or SSIM, on spatial windows.

Usage

cmsc_sw(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  ksize = 9,  globe = FALSE,  comp = "si")cmsc_e1_sw(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  ksize = 9,  globe = FALSE,  comp = "si")cmsc_e2_sw(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  ksize = 9,  globe = FALSE,  comp = "si")gcsm_sw(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  ksize = 9,  globe = FALSE,  comp = "si")ssim_sw(  x,  y,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  ksize = 11,  sigma = 1.5,  globe = FALSE,  comp = "si")

Arguments

x

A matrix.

y

The other matrix.

rescale

Rescale or not before computation.

xmin,xmax,ymin,ymax

Normalization parameters. IfNA, are calculatedfrom the ranges ofx andy, respectively. See Details.

ksize

Side length of spatial windows.

globe

Are data at the global scale? IfTRUE, two vertical borderswill be padded before computation.

comp

Variable to return. If"si", the composite measure, if"s1","s2" or"s3", the corresponding component.

sigma

Standard deviation of Gaussian weighting functiondepending on the distance between the cell and kernel center.

Details

These functions slide the spatial window over space. Missing values areomitted. Normalization parameters are used to rescalex andy, anddetermine the global minimum (min) and maximum (max). Ifrescale isTRUE,x andy are rescaled to(x-xmin)/(xmax-xmin) and(y-ymin)/(ymax-ymin); and setmin=0,max=1. IfFALSE,min=min(xmin,ymin),max=max(xmax,ymax). OpenMP is used for parallelcomputing.

Value

A matrix.

Examples

x = matrix(runif(36), nrow = 6, ncol = 6)gcsm_sw(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1, ksize = 3)cmsc_sw(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1, ksize = 3)ssim_sw(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1, ksize = 3)

Composite similarity on temporal windows

Description

Compute composite measures, GCSM or CMSC, on temporal windows.

Usage

cmsc_tw(  xxx,  yyy,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")cmsc_e1_tw(  xxx,  yyy,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")cmsc_e2_tw(  xxx,  yyy,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")gcsm_tw(  xxx,  yyy,  rescale = FALSE,  xmin = NA_real_,  xmax = NA_real_,  ymin = NA_real_,  ymax = NA_real_,  comp = "si")

Arguments

xxx

A 3-d array with the 3rd dimension representing time.

yyy

The other 3-d array.

rescale

Rescale or not before computation.

xmin,xmax,ymin,ymax

Normalization parameters. IfNA, are calculatedfrom the ranges ofxxx andyyy, respectively. See Details.

comp

Variable to return. If"si", the composite measure, if"s1","s2" or"s3", the corresponding component.

Details

These functions slide the temporal window over space. Missing values areomitted. Normalization parameters are used to rescalexxx andyyy, anddetermine the global minimum (min) and maximum (max). Ifrescale isTRUE,xxx andyyy are rescaled to(xxx-xmin)/(xmax-xmin) and(yyy-ymin)/(ymax-ymin); and setmin=0,max=1. IfFALSE,min=min(xmin,ymin),max=max(xmax,ymax). OpenMP is used for parallelcomputing.

Value

A matrix.

Examples

x = array(runif(81), dim = c(3, 3, 9))gcsm_tw(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)cmsc_tw(x, x + 0.2, xmin = 0, xmax = 1, ymin = 0, ymax = 1)

[8]ページ先頭

©2009-2025 Movatter.jp