You've already forked lazarus-ccr
LazStats: Refactor ABCNestedUnit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7865 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -100,54 +100,12 @@ procedure HomogeneityTest(
|
||||
NoCases : integer
|
||||
);
|
||||
|
||||
function CheckFactorCodes(AFactorName: String; const ACodes: DblDyneVec): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Utils, MatrixUnit, MathUnit;
|
||||
|
||||
{ Checks whether the codes provided are integers and whether the codes are
|
||||
consecutive, i.e. without gaps. }
|
||||
function CheckFactorCodes(AFactorName: String; const ACodes: DblDyneVec): Boolean;
|
||||
const
|
||||
EPS = 1E-9;
|
||||
NonIntegerError = 'Factor "%s" contains non-integer values.';
|
||||
NonConsecutiveError = 'Factor "%s" does not contain consecutive codes.';
|
||||
var
|
||||
values: DblDyneVec;
|
||||
i, prev, curr: Integer;
|
||||
begin
|
||||
Result := false;
|
||||
values := VecCopy(ACodes);
|
||||
SortOnX(values);
|
||||
if abs(values[0] - trunc(values[0])) > EPS then
|
||||
begin
|
||||
ErrorMsg(NonIntegerError, [AFactorName]);
|
||||
exit;
|
||||
end;
|
||||
prev := round(values[0]);
|
||||
|
||||
for i := 1 to High(values) do
|
||||
begin
|
||||
if abs(values[i] - trunc(values[i])) > EPS then
|
||||
begin
|
||||
ErrorMsg(NonIntegerError, [AFactorName]);
|
||||
exit;
|
||||
end;
|
||||
curr := round(values[i]);
|
||||
if curr - prev > 1 then
|
||||
begin
|
||||
ErrorMsg(NonConsecutiveError, [AFactorName]);
|
||||
exit;
|
||||
end;
|
||||
prev := curr;
|
||||
end;
|
||||
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tukey(error_ms : double; { mean squared for residual }
|
||||
error_df : double; { deg. freedom for residual }
|
||||
value : double; { size of smallest group }
|
||||
|
Reference in New Issue
Block a user