The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information.... |
Home ![]() ![]() ![]() |
|
Interface of SDL_Statis |
|
const {$IFDEF PAIDVERS} SDLVersionInfo = 'statis_r1070_full'; IsLightEd = false; {$ELSE} SDLVersionInfo = 'statis_r1070_lighted'; IsLightEd = true; {$ENDIF} release = 1070; type ESDLStatisError = class(ESDLError); { exception type to indicate errors } TSignifLevel = (Dot20, Dot15, Dot10, Dot05, Dot01); TSignifLevelEx = (Dot001, Dot002, Dot005, Dot010, Dot020, Dot050, Dot100, Dot200, Dot500); TtTestVersion = (ttPaired, ttHomoScedastic, ttHeteroScedastic); TRandGen = class (TComponent) private FLowBorder : double; FHighBorder : double; FResolution : integer; FDistVec : array of double; procedure SetResolution (res: integer); function GetProbability (Idx: integer): double; function GetRandNum: double; function GetLambda (ix: integer): double; procedure SetProbability (Idx: integer; Value: double); public constructor Create (AOwner: TComponent); override; destructor Destroy; override; property Lambda[ix: integer]: double read GetLambda; procedure Normalize; function Standardize: boolean; procedure NormalDistri (m, s: double); property Probability[ix: integer]: double read GetProbability write SetProbability; property Random: double read GetRandNum; function IndexOfLambda (Lambda: double): integer; procedure tDistri (df: integer); procedure Chi2Distri (df: integer); procedure FDistri (df1, df2: integer); procedure UniformDistri; procedure WeibullDistri (beta, eta: double); published property HighBorder: double read FHighBorder write FHighBorder; property LowBorder: double read FLowBorder write FLowBorder; property Resolution: integer read FResolution write SetResolution; end; TOnModelApplyRequestEvent = procedure (Sender: TObject; PercentDone: integer; Predictors: TDoubleArray; var Response: TDoubleArray) of object; TOnModelCreateRequestEvent = procedure (Sender: TObject; PercentDone: integer; ObjectList: TIntArray; var Success: boolean) of object; TCrossValidator = class(TComponent) private FTestSize : integer; FPress : TVector; FIsRunning : boolean; FTPCnt : TVector; // true positive count FFPCnt : TVector; // false positive count FTNCnt : TVector; // true negative count FFNCnt : TVector; // false negative count FXMat : TMatrix; // pointer to external descriptor matrix (X) FYMat : TMatrix; // pointer to external response matrix (Y) FOnModelApplyRequest : TOnModelApplyRequestEvent; FOnModelCreateRequest : TOnModelCreateRequestEvent; FOnCheckAbort : TOnCheckAbortEvent; procedure SetTestSize (size: integer); function GetRMSEP(ix: integer): double; function GetTPRate(ix: integer): double; function GetFPRate(ix: integer): double; public constructor Create (AOwner: TComponent); override; destructor Destroy; override; function Execute: boolean; property IsExecuting: boolean read FIsRunning; property RMSEP[varix: integer]: double read GetRMSEP; property TPRate [varix: integer]: double read GetTPRate; property FPRate [varix: integer]: double read GetFPRate; published property XMat: TMatrix read FXMat write FXMat; property YMat: TMatrix read FYMat write FYMat; property SizeTestSet: integer read FTestSize write SetTestSize; property OnModelApplyRequest: TOnModelApplyRequestEvent read FOnModelApplyRequest write FOnModelApplyRequest; property OnModelCreateRequest: TOnModelCreateRequestEvent read FOnModelCreateRequest write FOnModelCreateRequest; property OnCheckAbort: TOnCheckAbortEvent read FOnCheckAbort write FOnCheckAbort; end; TPLSSclMode = (scmCenter, scmStandardize); {$IFDEF PAIDVERS} TPLSModel = class(TComponent) private FScoreX : TMatrix; FScoreY : TMatrix; FLoadX : TMatrix; FLoadY : TMatrix; FWgtX : TMatrix; FOrthoLd : TMatrix; FVarX : TVector; FVarY : TVector; FCvdRmsEP : TVector; FCvdFPRate : TVector; FCvdTPRate : TVector; FCfThresh : TVector; FIsDAModel : boolean; FXMat : TMatrix; FYMat : TMatrix; FNFact : integer; FRegCoeffs : TMatrix; FXNames : array of TDTNameStr; // names of predictors FYNames : array of TDTNameStr; // names of response variables FScalMod : TPLSSclMode; FOnPercentDone : TOnPercentDoneEvent; FOnCheckCVDAbort: TOnCheckAbortEvent; function GetPredName (ix: integer): string; procedure SetPredName (ix: integer; value: string); function GetRespoName (ix: integer): string; procedure SetCFThresholds (YHat: TMatrix); procedure SetRespoName (ix: integer; value: string); procedure CVDModelApplyRequest(Sender: TObject; PercentDone: integer; Predictors: TDoubleArray; var Response: TDoubleArray); procedure CVDModelCreateRequest(Sender: TObject; PercentDone: integer; ObjectList: TIntArray; var Success: Boolean); procedure CVDModelCheckAbort (Sender: TObject; var AbortProcess: boolean); procedure SetNFactors (nfac: integer); procedure PercDone (Sender: TObject; Percent: longint); public constructor Create (AOwner: TComponent); override; destructor Destroy; override; property ScoreX: TMatrix read FScoreX; property ScoreY: TMatrix read FScoreY; function LoadModelCoefficients (FileName: string; var Comment: string): integer; property LoadX: TMatrix read FLoadX; property LoadY: TMatrix read FLoadY; property NamePredictor[ix: integer]: string read GetPredName write SetPredName; property NameResponse[ix: integer]: string read GetRespoName write SetRespoName; property OrthoLd: TMatrix read FOrthoLd; property WgtX: TMatrix read FWgtX; property VarX: TVector read FVarX; property VarY: TVector read FVarY; property ClassifThreshold: TVector read FCfThresh; property RegCoeff: TMatrix read FRegCoeffs; procedure SaveModelCoefficients (FileName, Comment: string); procedure AppendModelParamsToFile (var OFile: TextFile; Comment: string); property XMat: TMatrix read FXMat write FYMat; property YMat: TMatrix read FYMat write FYMat; procedure CalculateModel; function MaxFactors: integer; procedure Predict (XData: TDoubleArray; var YHat: TDoubleArray); overload; procedure Predict (XData: TMatrix; var YHat: TMatrix); overload; property CvdRmsEP: TVector read FCvdRmsEP; property CvdFPRate: TVector read FCvdFPRate; property CvdTPRate: TVector read FCvdTPRate; function CrossValidateModel (SizeTestSet: integer): double; published property Factors: integer read FNFact write SetNFactors; property IsDiscriminantModel: boolean read FIsDAModel write FIsDAModel; property ScalingMode: TPLSSclMode read FScalMod write FScalMod; property OnCheckCVDAbort: TOnCheckAbortEvent read FOnCheckCVDAbort write FOnCheckCVDAbort; property OnPercentDone: TOnPercentDoneEvent read FOnPercentDone write FOnPercentDone; end; {$ENDIF} const NumericSigLevel : array[TSignifLevelEx] of double = (0.001, 0.002, 0.005, 0.010, 0.020, 0.050, 0.100, 0.200, 0.500); function BinomCoeff (n : integer; { total number of elements } k : integer) { number of drawn elements } : longint; { binomial coefficient } function Anova1F (Data : TVector; { collection of data to be analyzed } TmLevel : TIntVector; { level of treatment of each data point } var SSTm, SSErr, SSTotal : double; { sum of squares } var DFTm, DFErr, DFTotal : integer; { degrees of freedom } var FSTat : double) { F value } : double; { p-value } function CalcFishQ (m1,m2, { mean values, class 1 & 2 } s1,s2 : double) { standard deviations } : double; { Fisher ratio } function Chi2DistriDensity (chi2 : double; { chi square quantile } df : integer) { degrees of freedom } : double; { density of chi square distribution } function chi2DistriIntegral (chi2 : double; { chi square quantile } df : integer) { degrees of freedom } : double; { probability } function chi2DistriQuantile (p : double; { probability } df : integer) { degrees of freedom } : double; { quantile of chi2-distribution } function ConfidenceInterval (alpha : double; { level of significance } StdDev : double; { standard deviation } NumData : integer) { sample size } : double; { confidence interval } function DeanDixonCriticalValues (NData : integer; { number of data } SigLevel : TSignifLevelEx) { level of significance } : double; { critical value } function DeanDixonTest (Data : TVector; { data to be tested } SigLevel : TSignifLevelEx; { level of significance } var Statistic : double) { test statistic } : integer; { index of outlier } function Erf (x : double) { parameters } : double; { function result } function ErfApprox (x : double) { parameters } : double; { function result } procedure EstimateProbDensity (const SampleData : TVector; { sample data } var Probability : TVector; { resulting prob. density } LowBorder, { lower border of estimation } HighBorder, { upper border of estimation } Smoothing : double; { width of the Gaussian kernel } WindowWidth : double; { width of local density estimation } Resolution : integer; { resolution of the prob. density } var MinDensIx, { minium density } MaxDensIx : integer; { maximum density } Feedback : TFeedbackProc); { feedback routine } function FDistriDensity (F : double; { F quantile } df1, df2 : integer) { degrees of freedom } : double; { density of F distribution } function FDistriIntegral (F : double; { F quantile } df1 : integer; { degrees of freedom } df2 : integer) { degrees of freedom } : double; { probability } function FDistriQuantile (p : double; { probability } df1 : integer; { degrees of freedom } df2 : integer) { degrees of freedom } : double; { quantile } function FisherTransform (x : double) { argument } : double; { Fisher's transform } function FisherTransformInv (x : double) { argument } : double; { inverse Fisher transform } function GrubbsCriticalValues (NData : integer; { number of data points } alpha : double; { level of significance } twosided : boolean) { TRUE: two-sided test } : double; { critical value for 2-sided Grubbs test } function GrubbsTest (Data : TVector; { data to be tested } SigLevel : double; { level of significance } var Statistic : double) { test statistic } : integer; { index of outlier } function HyperGeoDistriDensity (p : double; { probability of interesting cases } npop : integer; { total number of cases } nsample : integer; { no. of samples drawn } k : integer) { no. of interesting cases to be expected } : double; { probab. to observe exactly k interesting cases } function IncompleteBeta (x : double; { quantile } a, b : double) { parameters } : double; { function result } function IncompleteGamma (x, a : double): { parameters } double; { function result } function KolmogSmir1SampleTestStat (SampleSize : integer; { size of sample to be tested } alpha : TSignifLevel) { level of significance } : double; { critical KS value } function KSPValue (NumData : integer; { sample size } KSD : double) { Kolmogorov-Smirnov test statistic } : double; { p-value corresponding to KSD } function KSQuantile (NumData : integer; { sample size } alpha : TSignifLevel) { level of significance } : double; { critical value } function LillieforsPValue (NumData : integer; { sample size } KSD : double) { Lilliefors test statistic } : double; { p-value corresponding to KSD } function LillieforsQuantile (NumData : integer; { sample size } alpha : double) { level of significance } : double; { critical value } function LnBeta (z,w : double) { arguments of beta function } : double; { Beta(z,w) } function LnBinomCoeff (n : integer; { total number of elements } k : integer) { number of drawn elements } : double; { logarithm of binomial coefficient } function LnGamma (x : double) { argument of gamma function } : double; { ln(gamma(x)) } function LoadPLSModelComment (FileName : string; var Comment : string) : integer; function nDistriDensity (u : double) { critical value } : double; { density of normal distribution } function nDistriIntegral (u : double) { argument } : double; {integral of norm.dens.funct.} function nDistriQuantile (p : double) { probability } : double; { normal distribution } function PercentileOfArray (Data : TDoubleArray; { 1D data array } prob : double; { probability } FirstIx, LastIx : integer;{ first and last index of region to be checked } var Percentile : double) { calculated percentile } : integer; { error code } function Perform2SampleTTest (Data1, Data2 : TVector; { data points of the two samples } TestType : TtTestVersion; { kind of t-test to be performed } OneSided : boolean) { TRUE: one sided probability } : double; overload; { probability } function Perform2SampleTTest (Data1, Data2 : TVector; { data points of the two samples } TestType : TtTestVersion; { kind of t-test to be performed } OneSided : boolean; { TRUE: one sided probability } var Mean1, Mean2, { means of the two samples } Stdv1, Stdv2, { standard deviations of the two samples } MeanDiff, { mean of difference of sample pairs } StdDiff, { standard deviation of difference of sample pairs } tStatistic : double; { t-statistic } var df : integer) { degrees of freedom } : double; overload; { probability } function PerformKSNormalityTest (Data : TVector; { sample observations } IsSorted : boolean) { TRUE: vector is already sorted in asc. order } : double; { KS statistic } function PerformLillieforsTest (Data : TVector; { sample observations } IsSorted : boolean) { TRUE: vector is already sorted in asc. order } : double; { Lilliefors statistic } function PerformMannWhitneyUTest (Data1, Data2 : TVector; { data points of the two samples } OneSided : boolean; { TRUE: one sided probability } var UStatistic : double) { U-statistic } : double; { probability } function ExactRunsTest (gs1, gs2 : integer; { group sizes } observed : integer) { number of observed runs } : double; { propability to find the observed number of runs } function RunsTest (Data : TBitFld; { binary data } var p : double) { associated level of significance } : boolean; { TRUE: sequence of values is non-random } function RunsTestSerial (Data : TVector; { data to be tested for serial randomness } var p : double) { associated level of significance } : boolean; { TRUE: sequence of values is non-random } function tDistriDensity (t : double; { t value } df : integer) { degrees of freedom } : double; { density of t distribution } function tDistriIntegral (t : double; { t value } df : integer) { degrees of freedom } : double; { probability } function tDistriQuantile (p : double; { probability } df : integer) { degrees of freedom } : double; { quantile of t-distribution } function UDistriDensity (U : integer; { U statistic } M, N : integer) { number of data of each distribution } : double; { density of the U distribution } function UDistriIntegral (U : integer; { U statistic } M, N : integer) { number of data of each distribution } : double; { probability } function UDistriQuantile (m, n : integer; { number of data of each distribution } prob : double) { probability } : integer; { quantile of U-distribution } function WeibullDensity (x : double; { argument } beta : double; { parameters of Weibull distribution } eta : double) : double; { density } function WilcoxonSRQuantile (NData : integer; { number of data points } alpha : double; { level of significance } twosided : boolean) { TRUE: two-sided test } : integer; { critical value for Wilcoxon signed rank test } function ShapiroWilkTest (Data : TVector; { data vector } NCens : integer; { number of right censored data } var pW : double; { p-value of WStat } var WStat : double) { W statistics } : integer; { error number } function ShapiroWilkIntegral (WStat : double; { W statistic of the Shapiro-Wilk test } NDat, { number of data } NCens : integer) { number of censored data } : double; { integral }
|