Declaration: SpectralSimilarity (Spec1, Spec2: TDoubleArray; FirstIx, LastIx: integer; SimOp: TSpecSimi; var Similarity: double): integer;
The function SpectralSimilarity calculates one of several spectral similarity measures. The parameters Spec1 and Spec2 contain the spectra to be compared, the parameter SimOp defines the type of similarity measure to be calculated. The parameters FirstIx and LastIx specify the range of the spectral vectors to be used for the calculation. The valid range for both parameters is 0...Min(length(Spec1),length(Spec2))-1.

Setting both FirstIx and LastIx to zero values causes the entire spectral vectors to be used for the calculation. In this case the length of Spec1 and Spec2 must be equal.

Currently the following similarity measures are supported:

  • spsEuclidean ... Euclidean distance in the p-dimensional space (p = LastIx-FirstIx+1)
  • spsCorr ... Pearson's correlation coefficient of the two spectra
  • spsSigCorr ... significant correlation only - a correlation is returned only if the correlation is significant, otherwise a zero value is returned
  • spsSpecAngle ... angle between the two spectral vectors
On return, the variable parameter Similarity contains the calculated similarity measure.

The function returns one of the following error codes:

 0 ... everything is OK
-1 ... FirstIx is out of range
-2 ... LastIx is out of range
-3 ... length of Spec1 and Spec2 do not match (checked only if FirstIx and LastIx are both zero)