medoidSP {sarp.snowprofile.alignment} | R Documentation |
Find the medoid snow profile among a group of profiles
Description
Find the medoid snowprofile among a group of profiles, based on their pairwise dissimilarity. Either provide a list
of snowprofile
objects, or a precomputed distance matrix.
If you provide a list of profiles the profiles can optionally be rescaled and resampled before the distance matrix
for the medoid calculation is computed. When computing the distance matrix this routine calls distanceSP for
every possible pair of profiles among the group. During that call the profile pair is aligned by dtwSP
and the aligned pair is evaluated by simSP.
Note that the number of possible profile pairs grows exponentially with the number of profiles in the group (i.e.,
O(n^2) calls, where n is the number of profiles in the group).
Usage
medoidSP(
profileList = NULL,
rescale_resample = TRUE,
retDistmat = FALSE,
distmat = NULL,
verbose = FALSE,
resamplingRate = 0.5,
progressbar = requireNamespace("progress", quietly = TRUE),
...
)
Arguments
profileList |
List of snowprofile objects |
rescale_resample |
Do you want to uniformly rescale and resample the set of profiles prior to calculating the distance matrix? |
retDistmat |
Do you want to return the pairwise distance matrix? |
distmat |
If you have a precalculated distance matrix, provide it here to compute the medoid on it. |
verbose |
print pairwise distance matrix? default FALSE |
resamplingRate |
The resampling rate that is used for the whole set if |
progressbar |
Do you want to print a progress bar with recommended package "progress"? |
... |
arguments passed to distanceSP and then further to dtwSP |
Details
Note that the pairwise distance matrix is modified within the function call to represent a symmetric distance matrix.
That is,, however, not originally the case, since dtwSP(A, B) != dtwSP(B, A)
. The matrix is therefore made symmetric by
setting the similarity between the profiles A and B to max({dtwSP(A, B), dtwSP(B, A)})
.
Value
If retDistmat = FALSE
return the (named) index of the medoid snow profile, otherwise return a list with the elements
iMedoid
and distmat
.
Author(s)
fherla
See Also
Examples
this_example_runs_about_5s <- TRUE
if (!this_example_runs_about_5s) { # exclude from cran checks
## take a list of profiles
grouplist <- SPgroup[1:4]
plot(grouplist, SortMethod = 'unsorted', xticklabels = "originalIndices")
## calulate medoid profile
idxMedoid <- medoidSP(grouplist)
representativeProfile <- grouplist[[idxMedoid]]
plot(representativeProfile, main = paste0("medoid (i.e., profile ", idxMedoid, ")"))
}