PaddingType: SAPaddingType;
The PaddingType property determines series padding or truncating method.
If the length of source series is padded with zeroes, that is, PaddingType = SAPaddingType.PadByZeros, the number of zeroes is specified in the ISmUnivariateSpectrumAnalysis.ZerosCount property.
To execute the example, add a link to the Stat system assembly.
// Data output procedure
Public Sub Print(Data: Array Of Double);
Var
i: Integer;
d: Double;
Begin
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data[i]) Then
Debug.WriteLine(i.ToString + ": ---empty---");
Else d := Data[i];
Debug.WriteLine(i.ToString + ": " + d.ToString);
End If;
End For;
End Sub Print;
Sub UserProc;
Var
sp: SmUnivariateSpectrumAnalysis;
d0: Double;
res, i: Integer;
s: Array[40] Of Double;
Begin
// Initial data
s[0] := 0.599; s[10] := 0.586;
s[1] := 0.586; s[11] := 0.578;
s[2] := 0.556; s[12] := 0.568;
s[3] := 0.549; s[13] := 0.537;
s[4] := 0.531; s[14] := 0.506;
s[5] := 0.528; s[15] := 0.512;
s[6] := 0.497; s[16] := 0.475;
s[7] := 0.444; s[17] := 0.444;
s[8] := 0.401; s[18] := 0.410;
s[9] := 0.309; s[19] := 0.364;
s[20] := 0.627; s[30] := 0.599;
s[21] := 0.562; s[31] := 0.543;
s[22] := 0.540; s[32] := 0.519;
s[23] := 0.537; s[33] := 0.512;
s[24] := 0.500; s[34] := Double.Nan;
s[25] := 0.500; s[35] := 0.494;
s[26] := 0.475; s[36] := 0.469;
s[27] := 0.451; s[37] := 0.469;
s[28] := 0.451; s[38] := Double.Nan;
s[29] := 0.444; s[39] := Double.Nan;
// Create a method
sp := New SmUnivariateSpectrumAnalysis.Create;
// Initial data series
sp.Serie.Value := s;
// Sample period
sp.ModelPeriod.FirstPoint := 1;
sp.ModelPeriod.LastPoint := 40;
// Share of boundary data
sp.DataProportion := 0.5;
// Lag window
sp.LagWindow := LagWindowType.Bartlett;
// Type of initial adjustment
sp.InitCorrection := InitCorrectionType.MeanCorrection;
// Truncation point
sp.CutOffPoint := 1;
// Method of series padding or truncating
sp.PaddingType := SAPaddingType.PadByZeros;
sp.ZerosCount := 2;
// Use fast Fourier transform
sp.UseFastFourierTransform := True;
// Order of fast Fourier transform
sp.FastFourierTransformOrder := 3;
// Method of missing data treatment
sp.MissingData.Method := MissingDataMethod.SampleAverage;
// Run calculation
res := sp.Execute;
If res <> 0 Then
Debug.WriteLine(sp.Errors);
Else
// Output results
For i := 0 To sp.WarningsCount - 1 Do
Debug.WriteLine(sp.Warnings[i]);
End For;
d0 := sp.SpectrumStatistics.LCL;
Debug.WriteLine("Lower confidence bound: " + d0.ToString);
d0 := sp.SpectrumStatistics.UCL;
Debug.WriteLine("Upper confidence bound: " + d0.ToString);
d0 := sp.SpectrumStatistics.BW;
Debug.WriteLine("Passband: " + d0.ToString);
d0 := sp.SpectrumStatistics.DF;
Debug.WriteLine("Number of degrees of freedom: " + d0.ToString);
Debug.WriteLine("Periodogram");
Print(sp.Periodogramm);
Debug.WriteLine("Spectral density");
Print(sp.Spectrum);
Debug.WriteLine("Spectral frequency");
Print(sp.SpectrumFrequency);
Debug.WriteLine("Spectral periods");
Print(sp.SpectrumPeriod);
Debug.WriteLine("Weights");
Print(sp.Weights);
End If;
End Sub UserProc;
After executing the example, spectral analysis is calculated. Calculation results are displayed to the console window.
See also: