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

Revision 9fbfbef539cfc60884f6828c62f0aa328335a0b1 authored by Toni Giorgino on 08 January 2008, 00:00:00 UTC, committed by Gabor Csardi on 08 January 2008, 00:00:00 UTC
version 1.5-3
1 parent da02fed
  • Files
  • Changes
  • 95bce6f
  • /
  • demo
  • /
  • dtw.R
Raw File Download
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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:9fbfbef539cfc60884f6828c62f0aa328335a0b1
directory badge Iframe embedding
swh:1:dir:6fc9a058a52b8529dcb3774c9f49b31bd3f9f125
content badge Iframe embedding
swh:1:cnt:3cc9854ce986cf39bbda87b8206069d33d60b41d
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.

  • revision
  • directory
  • content
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 ...
dtw.R
## $Id: dtw.R 51 2007-12-11 10:59:08Z tonig $


## Show off some dtw capabilities on a sine/cosine
## alignment toy problem

## Load the library and pause at each plot
library(dtw);
opar<-par(ask=TRUE);


## A noisy sine wave as query
idx<-seq(0,6.28,len=100);
query<-sin(idx)+runif(100)/10;
template<-cos(idx);

## A cosine is for template; sin and cos are offset by 25 samples
dtw(query,template,keep=TRUE)->alignment;

## Display the mapping with reference
plot(alignment$index1,alignment$index2);
lines(1:100-25,col="red")

## We can also make a nice three-way plot
## Beware of the template's y axis, may be confusing
plot(alignment,xts=query,yts=template,type="threeway");


## A profile of the cumulative distance matrix
plot(alignment,type="density");


## Do the same with asymmetric step
dtw(query,template,keep=TRUE,step=asymmetric)->ita;
plot(ita,type="density",main="Sine and cosine, asymmetric step");


## Windowing functions (global constraints) can be applied and plotted
dtwWindow.plot(itakuraWindow, main="So-called Itakura parallelogram window");


## Symmetric step with global parallelogram-shaped constraint
## Note how long (>2 steps) horizontal stretches are allowed within the window.
dtw(query,template,keep=TRUE,window=itakuraWindow)->ita;
dtwPlot(ita,type="density",main="Symmetric step with Itakura parallelogram window");


## Asymmetric step with slope constraint
## The "Itakura parallelogram" arises from the local constraint
## plus the boundary condition. Three sides of the parallelogram are seen
dtw(query,template,keep=TRUE,step=asymmetricItakura)->ita;
dtwPlot(ita,type="density",main="Slope-limited asymmetric step (Itakura)");



## Local and global constraint can be in effect at the same time
## Sakoe-chiba band, plus asymmetric step pattern
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")



## Demo ends here
par(opar);
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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

back to top