Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/cran/dtw
28 September 2022, 07:50:27 UTC
  • Code
  • Branches (54)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.1-2
    • refs/tags/0.3-1
    • refs/tags/0.4-2
    • refs/tags/1.0-2
    • refs/tags/1.12-3
    • refs/tags/1.12-5
    • refs/tags/1.13-1
    • refs/tags/1.14-1
    • refs/tags/1.14-3
    • refs/tags/1.15
    • refs/tags/1.16
    • refs/tags/1.17-1
    • refs/tags/1.18-1
    • refs/tags/1.2-1
    • refs/tags/1.20-1
    • refs/tags/1.21-1
    • refs/tags/1.21-3
    • refs/tags/1.22-3
    • refs/tags/1.23-1
    • refs/tags/1.4-3
    • refs/tags/1.5-3
    • refs/tags/1.6-2
    • refs/tags/1.9-1
    • refs/tags/R-2.10.0
    • refs/tags/R-2.10.1
    • refs/tags/R-2.11.0
    • refs/tags/R-2.11.1
    • refs/tags/R-2.12.0
    • refs/tags/R-2.12.1
    • refs/tags/R-2.12.2
    • refs/tags/R-2.13.0
    • refs/tags/R-2.13.1
    • refs/tags/R-2.13.2
    • refs/tags/R-2.14.0
    • refs/tags/R-2.14.1
    • refs/tags/R-2.14.2
    • refs/tags/R-2.15.0
    • refs/tags/R-2.15.1
    • refs/tags/R-2.15.2
    • refs/tags/R-2.15.3
    • refs/tags/R-2.6.2
    • refs/tags/R-2.7.0
    • refs/tags/R-2.7.1
    • refs/tags/R-2.7.2
    • refs/tags/R-2.8.0
    • refs/tags/R-2.8.1
    • refs/tags/R-2.9.0
    • refs/tags/R-2.9.1
    • refs/tags/R-2.9.2
    • refs/tags/R-3.0.0
    • refs/tags/R-3.0.1
    • refs/tags/R-3.0.2
    • refs/tags/R-3.0.3
    No releases to show
  • 5f7f2f7
  • /
  • man
  • /
  • dtwWindowingFunctions.Rd
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:dd0882d41e04b6c7b4c72c0c314c7351a6086a85
origin badgedirectory badge Iframe embedding
swh:1:dir:ae2b92708697bf791cf6ce0bd1259829c7247b2d
origin badgerevision badge
swh:1:rev:7e56ce3aad7a130f3145baa08991cdcea6ce717b
origin badgesnapshot badge
swh:1:snp:e75a8a2617c9395688cff068aec5b1e7448d2a41
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 7e56ce3aad7a130f3145baa08991cdcea6ce717b authored by Toni Giorgino on 01 June 2008, 00:00:00 UTC
version 1.6-2
Tip revision: 7e56ce3
dtwWindowingFunctions.Rd
\name{dtwWindowingFunctions}
\alias{noWindow}
\alias{sakoeChibaWindow}
\alias{slantedBandWindow}
\alias{itakuraWindow}
\alias{dtwWindowingFunctions}
\alias{dtwWindow.plot}



\title{Global constraints and windowing functions for DTW}
\description{
  Various global constraints (windows) which can be applied to
  the \code{window.type} argument of \code{\link{dtw}},
  including the Sakoe-Chiba band, the Itakura parallelogram,
  and custom functions.
}

\usage{
noWindow(iw, jw, ...);
sakoeChibaWindow(iw,jw,  window.size,...);
slantedBandWindow(iw,jw,query.size,template.size,  window.size,...);
itakuraWindow(iw,jw,query.size,template.size,  ...); 

dtwWindow.plot(fun,query.size=200,template.size=220,...);

}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{iw}{ index in the query (row) -- automatically set }
  \item{jw}{ index in the template (column) -- automatically set }
  \item{query.size}{ size of the query time series -- automatically set }
  \item{template.size}{ size of the template time series -- automatically set }
  \item{window.size}{ window size, used by some windowing functions -- must be set}
  \item{fun}{ a windowing function }
  \item{...}{additional arguments passed to windowing functions}
}

\details{

  Windowing functions can be passed to the
  \code{window.type} argument in \code{\link{dtw}} to put a global
  constraint to the warping paths allowed. They take two integer
  arguments (plus optional parameters) and must return a boolean value 
  \code{TRUE} if the coordinates fall within the allowed region 
  for warping paths, \code{FALSE} otherwise.

  User-defined functions can read variables \code{template.size},
  \code{query.size} and \code{window.size}; these are pre-set upon
  invocation.  Some functions require additional parameters which must
  be set (e.g. \code{window.size}).  User-defined functions are free to
  implement any window shape, as long as at least one path is allowed
  between the initial and final alignment points, i.e., they are
  compatible with the DTW constraints.

  The \code{sakoeChibaWindow} function implements the Sakoe-Chiba band,
  i.e. \code{window.size} elements around the \code{main} diagonal. If the
  window size is too small, i.e. if
  $\code{template.size}-\code{query.size} > \code{window.size}$, warping
  becomes impossible.

  An \code{itakuraWindow}  global constraint is still provided with this
  package.    See example below for a demonstration of
  the difference between a local the two.

  The \code{slantedBandWindow} (package-specific) is a band centered
  around the (jagged) line segment which joins element \code{[1,1]} to
  element \code{[query.size,template.size]}, and will be
  \code{window.size} columns wide. In other words, the "diagonal" goes
  from one corner to the other of the possibly rectangular cost matrix,
  therefore having a slope of \code{M/N}, not 1.

    \code{dtwWindow.plot} visualizes a windowing function. By default
  it plots a 200 x 220 rectangular region, which can
  be changed via \code{template.size} and \code{query.size} arguments.

  
}

\note{
  Although  \code{dtwWindow.plot} resembles object-oriented notation,
  there is not a such a dtwWindow class currently.

    A widely held misconception is that the "Itakura parallelogram" (as
  described in reference [2]) is a \emph{global} constraint, i.e. a
  window.  To the author's knowledge, it instead arises from the local
  slope restrictions imposed to the warping path, such as the one
  implemented by the \code{\link{asymmetricItakura}} step pattern.
}

\value{
  Windowing functions return \code{TRUE} if the coordinates passed as
  arguments fall within the chosen warping window, \code{FALSE}
  otherwise. User-defined functions should do the same.
}

\references{ 
[1] Sakoe, H.; Chiba, S., \emph{Dynamic programming algorithm optimization for spoken word recognition,}
 Acoustics, Speech, and Signal Processing [see also IEEE Transactions on Signal Processing], IEEE Transactions on , 
vol.26, no.1, pp. 43-49, Feb 1978 URL: \url{http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1163055} \cr
\cr
[2] Itakura, F., \emph{Minimum prediction residual principle applied to speech
recognition,} Acoustics, Speech, and Signal Processing [see also IEEE
Transactions on Signal Processing], IEEE Transactions on , vol.23, no.1, pp.
67-72, Feb 1975. URL: \url{http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1162641} 

}


\author{Toni Giorgino}

\examples{

## Display some windowing functions
dtwWindow.plot(itakuraWindow, main="So-called Itakura parallelogram window")
dtwWindow.plot(slantedBandWindow, window.size=2,
  template=13, query=17, main="The slantedBandWindow at window.size=2")


## Asymmetric step with Sakoe-Chiba band

idx<-seq(0,6.28,len=100); 
query<-sin(idx)+runif(100)/10;
template<-cos(idx);

asyband<-dtw(query,template,keep=TRUE,
             step=asymmetric,
             window.type=sakoeChibaWindow,
             window.size=30                  );

dtwPlot(asyband,type="density",main="Sine/cosine: asymmetric step, S-C window")


}


\concept{Dynamic Time Warp}
\concept{Global contraint}
\concept{Windowing}
\concept{Sakoe-Chiba Band}
\concept{Itakura Parallelogram}


\keyword{ ts }

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API