STATUS: unstable Distances between: points, signals, trials. More...
#include "array.h"
#include "linalg.h"
#include "clustering.h"
#include "definitions.h"
#include "recurrence_plot.h"
#include "nonlinear.h"
#include "warping.h"
#include "optarg.h"
Go to the source code of this file.
Typedefs | |
typedef double **(* | PointwiseDistanceFunction )(double *, int, double *, int, double **, OptArgList *) |
typedef double(* | VectorDistanceFunction )(const double *, const double *, int, OptArgList *) |
Functions | |
double | dist_point_line (double *p, double *x, double *y) |
Compute distance from point p to the line through points x and y. | |
Array * | distmatrix_signaldist (VectorDistanceFunction f, const Array *s1, const Array *s2, Array *out, OptArgList *optargs) |
Pointwise distance matrix:. | |
double ** | eeg_distmatrix (EEG *eeg, VectorDistanceFunction f, double **d, OptArgList *optargs) |
Array * | matrix_distmatrix (VectorDistanceFunction f, const Array *X, Array *D, OptArgList *optargs) |
double | pathdist_euclidean_dt (WarpPath *p1, WarpPath *p2) |
computes the distance between two warping-functions. | |
double ** | signaldist_euclidean (double *s1, int n1, double *s2, int n2, double **d, OptArgList *optargs) |
double ** | signaldist_euclidean_derivative (double *s1, int n1, double *s2, int n2, double **d, OptArgList *optargs) |
double ** | signaldist_stft (double *s1, int n1, double *s2, int n2, double **d, OptArgList *optargs) |
double ** | vectordist_distmatrix (VectorDistanceFunction f, const double **X, int n, int p, double **D, ProgressBarFunction progress, OptArgList *optargs) |
double | vectordist_dtw (const double *x1, const double *x2, int p, OptArgList *optargs) |
double | vectordist_euclidean (const double *x1, const double *x2, int p, OptArgList *optargs) |
Euclidean distance between vector x1 and x2. | |
double | vectordist_euclidean_normalized (const double *x1, const double *x2, int p, OptArgList *optargs) |
Euclidean distance between normalized vector x1 and x2. | |
double | vectordist_regularized_dtw (const double *x1, const double *x2, int p, OptArgList *optargs) |
STATUS: unstable Distances between: points, signals, trials.
The distances (functions starting with vectordist_*()) are between two vectors of the same size, i.e. they calculate
for two vectors and some metric. vectordist_distmatrix() applies one of these functions to all pairs of columns in the matrix, yielding a distance matrix
Definition in file distances.h.
typedef double**(* PointwiseDistanceFunction)(double *, int, double *, int, double **, OptArgList *) |
Definition at line 54 of file distances.h.
typedef double(* VectorDistanceFunction)(const double *, const double *, int, OptArgList *) |
Definition at line 55 of file distances.h.
double dist_point_line | ( | double * | p, | |
double * | x, | |||
double * | y | |||
) |
Compute distance from point p to the line through points x and y.
d = abs(det([y-x;p-x]))/norm(y-x);
p | point in question (x,y)-plane | |
x,y | points specify the line x=(x_1,x_2), y=(y_1, y_2) |
Definition at line 330 of file distances.c.
Array* distmatrix_signaldist | ( | VectorDistanceFunction | f, | |
const Array * | s1, | |||
const Array * | s2, | |||
Array * | out, | |||
OptArgList * | optargs | |||
) |
Pointwise distance matrix:.
f | the distance function between individual points in signals s1,s2 | |
s1 | a 2D (N1xp) array holding the (multivariate) time-series 1 | |
s1 | a 2D (N2xp) array holding the (multivariate) time-series 2 | |
out | either an NxN matrix, or NULL (allocated in function) | |
optargs | may contain many different arguments which are passed to the VectorDistanceFunction (see details there): |
Definition at line 98 of file distances.c.
double** eeg_distmatrix | ( | EEG * | eeg, | |
VectorDistanceFunction | f, | |||
double ** | d, | |||
OptArgList * | optargs | |||
) |
Compute trial-to-trial distance matrix for all trials in eeg-struct. Average over all channels in the EEG-struct.
eeg | the EEG-data | |
f | the function used to compare two ERPs | |
d | user allocated memory, or NULL -> own memory is alloc'ed | |
optargs | may contain:
|
Definition at line 269 of file distances.c.
Array* matrix_distmatrix | ( | VectorDistanceFunction | f, | |
const Array * | X, | |||
Array * | D, | |||
OptArgList * | optargs | |||
) |
build a distance matrix D from data X which consists of n observations with p features each. Observations are compared using f.
f | distance function | |
X | data (nxp) | |
D | output matrix or NULL -> own memory allocation | |
progress | NULL or a progressbar | |
optargs | may contain arguments for the vectordistancefunction f
|
Definition at line 36 of file distances.c.
computes the distance between two warping-functions.
It is assumed that both pathes have the same starting and endpoint.
Algorithm:
1. compute distance transform for p1
2. line-integral of p2 through DT(p1)
Definition at line 351 of file distances.c.
double** signaldist_euclidean | ( | double * | s1, | |
int | n1, | |||
double * | s2, | |||
int | n2, | |||
double ** | d, | |||
OptArgList * | optargs | |||
) |
pointwise distance matrix for euclidean metric.
optargs | is ignored |
Definition at line 412 of file distances.c.
double** signaldist_euclidean_derivative | ( | double * | s1, | |
int | n1, | |||
double * | s2, | |||
int | n2, | |||
double ** | d, | |||
OptArgList * | optargs | |||
) |
calculate
where
Derivatives are approximated with s'(t) = s(t)-s(t-1)
s1,s2 | ||
d | matrix or NULL (alloc'd in function) | |
optargs | can contain:
|
Definition at line 445 of file distances.c.
double** signaldist_stft | ( | double * | s1, | |
int | n1, | |||
double * | s2, | |||
int | n2, | |||
double ** | d, | |||
OptArgList * | optargs | |||
) |
calculate
where
s1,s2 | ||
d | matrix or NULL (alloc'd in function) | |
optargs | may contain:
|
Definition at line 523 of file distances.c.
double** vectordist_distmatrix | ( | VectorDistanceFunction | f, | |
const double ** | X, | |||
int | n, | |||
int | p, | |||
double ** | D, | |||
ProgressBarFunction | progress, | |||
OptArgList * | optargs | |||
) |
build a distance matrix D from data X which consists of n observations with p features each. Observations are compared using f.
f | distance function | |
X | data (nxp) | |
D | output matrix or NULL -> own memory allocation | |
progress | NULL or a progressbar | |
optargs | may contain arguments for the vectordistancefunction f |
Definition at line 642 of file distances.c.
double vectordist_dtw | ( | const double * | x1, | |
const double * | x2, | |||
int | p, | |||
OptArgList * | optargs | |||
) |
Distance which sums the absolute deviation from the main diagonal of the dtw-warp-path computed on x1 and x2.
x1,x2 | vectors of size p | |
optargs | may contain:
|
Definition at line 221 of file distances.c.
double vectordist_euclidean | ( | const double * | x1, | |
const double * | x2, | |||
int | p, | |||
OptArgList * | optargs | |||
) |
Euclidean distance between vector x1 and x2.
x1,x2 | vectors of size p | |
optargs | is ignored |
Definition at line 160 of file distances.c.
double vectordist_euclidean_normalized | ( | const double * | x1, | |
const double * | x2, | |||
int | p, | |||
OptArgList * | optargs | |||
) |
Euclidean distance between normalized vector x1 and x2.
Normalization is defined by
x1,x2 | vectors of size p | |
optargs | is ignored |
Definition at line 182 of file distances.c.
double vectordist_regularized_dtw | ( | const double * | x1, | |
const double * | x2, | |||
int | p, | |||
OptArgList * | optargs | |||
) |