Learn R Programming

sarp.snowprofile.alignment (version 1.0.2)

medoidSP: 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,
  ...
)

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 rescale_resample = TRUE

...

arguments passed to distanceSP

Value

If retDistmat = FALSE return the (named) index of the medoid snow profile, otherwise return a list with the elements iMedoid and distmat.

See Also

reScaleSampleSPx

Examples

Run this code
# NOT RUN {
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', labelOriginalIndices = TRUE)

  ## calulate medoid profile
  idxMedoid <- medoidSP(grouplist)
  representativeProfile <- grouplist[[idxMedoid]]
  plot(representativeProfile, main = paste0("medoid (i.e., profile ", idxMedoid, ")"))

}
# }

Run the code above in your browser using DataLab