DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


CreateGaussianPeaks

Declaration: CreateGaussianPeaks (PeakParams: TPeakParamsList; var Signal: TDoubleArray): integer;
The function CreateGaussianPeaks generates a signal which consists of one or more Gaussian peaks. The individual peaks are specified by the array PeakParams which is an open array of TGaussPeakParams. The first element of each entry of PeakParams (PeakParam[.][1]) specifies the position, the second (PeakParam[.][2]) the width and the third element (PeakParam[.][3]) contains the amplitude. Please note that both the position and the width refer to the index of the Signal array. Thus the length of the Signal array determines the resolution of the peaks. All defined peaks are added and the sum is stored in the Signal array.

The figure below shows the results of five calls to CreateGaussianPeaks plotted on top of each other. The Signal array had a length of 101 elements, in all calls a single peak was specified whose position (50) and intensity (1.0) were kept constant and whose width paremeter varied between 4 and 20.

The function returns the following error codes:

 0 ... everything is OK
-1 ... the PeakParams was empty or nil
-2 ... the length of Signal vector is too low (minimal required length is 3)

Example: As an example, the signal shown below has been generated from three Gaussian peaks, having the following parameters (the length of the Signal array was set to 101):

  Position Width Intensity
Peak 1: 20.0 8.0 1.0
Peak 2: 44.0 7.0 0.7
Peak 3: 60.0 10.0 1.5

The following code snippet was used to generate the signal shown above:

var
  Data           : TDoubleArray;
  PeakDef        : TPeakParamsList;

....
....

SetLength (Data, 101);   // create signal vector
SetLength (PeakDef,3);   // peak parameters
PeakDef[0][1] := 20;     // peak 1
PeakDef[0][2] := 8;
PeakDef[0][3] := 1.00;
PeakDef[1][1] := 44;     // peak 2
PeakDef[1][2] := 7;
PeakDef[1][3] := 0.70;
PeakDef[2][1] := 60;     // peak 3
PeakDef[2][2] := 10;
PeakDef[2][3] := 1.50;
CreateGaussianPeaks (PeakDef, Data);