From 82c367cb71dbc771c05947c75d3b8a218e4dc70a Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 23 Jun 2020 18:28:18 +0000 Subject: [PATCH] LazStats: more refactoring of BlkAnovaUnit. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7490 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../analysis/comparisons/blkanovaunit.pas | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas b/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas index a65ac49d8..51d247f7a 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas @@ -328,11 +328,11 @@ begin SetLength(cellsums, totcells); // array of cell sums then means // initialize array values - for i := 1 to totcells do + for i := 0 to totcells-1 do begin - cellsums[i-1] := 0.0; - cellvars[i-1] := 0.0; - cellcnts[i-1] := 0; + cellsums[i] := 0.0; + cellvars[i] := 0.0; + cellcnts[i] := 0; end; // do analysis @@ -361,6 +361,10 @@ begin BrownForsytheOneWay(lReport); if Welch.Checked then WelchOneWay(lReport); + + if not DisplayReport(lReport) then + exit; + if PlotMeans.Checked or Plot2DLines.Checked or Plot3DLines.Checked then OneWayPlot; end; @@ -382,6 +386,10 @@ begin begin TwoWayTable(lReport); TwoWayContrasts(lReport); + + if not DisplayReport(lReport) then + exit; + if PlotMeans.Checked or Plot2DLines.Checked or Plot3DLines.Checked then TwoWayPlot; end; @@ -418,6 +426,10 @@ begin begin ThreeWayTable(lReport); ThreeWayContrasts(lReport); + + if not DisplayReport(lReport) then + exit; + if (PlotMeans.Checked) or (Plot2DLines.Checked) or (Plot3DLines.Checked) then ThreeWayPlot; end; @@ -437,8 +449,6 @@ begin end; end; - DisplayReport(lReport); - finally lReport.Free; cellcnts := nil; @@ -727,12 +737,12 @@ begin SetLength(GraphFrm.Xpoints,1,NF1cells); maxmean := 0.0; - for i := 1 to NF1cells do + for i := 0 to NF1cells-1 do begin - cellsums[i-1] := cellsums[i-1] / cellcnts[i-1]; - GraphFrm.Ypoints[0,i-1] := cellsums[i-1]; - if cellsums[i-1] > maxmean then maxmean := cellsums[i-1]; - GraphFrm.Xpoints[0,i-1] := minF1 + i - 1; + cellsums[i] := cellsums[i] / cellcnts[i]; + GraphFrm.Ypoints[0, i] := cellsums[i]; + if cellsums[i] > maxmean then maxmean := cellsums[i]; + GraphFrm.Xpoints[0,i] := minF1 + i; end; GraphFrm.nosets := 1; GraphFrm.nbars := NF1cells;