Skip to content

Re-record statcond ANOVA fixtures for double-precision ANOVA (EEGLAB #977) - #16

Merged
suraj-ranganath merged 1 commit into
masterfrom
cursor/rerecord-statcond-anova-ba47
Oct 20, 2026
Merged

suraj-ranganath merged 1 commit into
masterfrom
cursor/rerecord-statcond-anova-ba47

Conversation

@suraj-ranganath

Copy link
Copy Markdown
Member

Replaces regression_tests/t_statcond.mat so the ANOVA expected values match EEGLAB after #977 (merge d0963be9d81acc5b66e84f8d3d7c89e3ce127cc4 on develop; which statcond resolved to functions/statistics/statcond.m). This commit changes that one file. It is not a Git LFS path.

What changed

Only the stored value of cases 3-6 and 15-30 was replaced. The recorder loads the original .mat, replaces test_N.value for N = 3:6 and 15:30, and writes with save(..., '-v7'). inputs, absTol / relTol, and every other case are kept. The inputs and the 0 tolerances are unchanged.

Of the 79 variables, 59 are raw byte-identical compressed blocks: inputs, test_1, test_2, test_7..14, and test_31..78. Only test_3..6 and test_15..30 differ, plus the 128-byte header text: Platform: GLNXA64, Created on: Sat Oct 17 14:15:44 2026 replaces the old PCWIN64 header. The new file is 324986 bytes (sha256 38fca08a69a7eb045c38874d303a652196c70ef4e4962682c774130b8a5a239f); the old file was 314608 bytes.

How they were recorded

MATLAB 25.2.0.3360999 (R2025b) Update 7, glnxa64, run with matlab-batch, on EEGLAB d0963be9. rng('default') is called before each case, as t_statcond.m does (TestMethodSetup). The TestClassSetup spelling fix (homogeneous to homogenous, inhomogeneous to inhomogenous) is applied to a copy of the inputs only. nargout is taken from t_statcond.m.

matlab-batch "addpath(genpath('/workspace/eeglab977/functions')); addpath('<eeglab_tests>/regression_tests'); addpath('<recorder dir>'); st977_record('<eeglab_tests>/regression_tests/t_statcond.mat', 'rec1.mat', [3:6 15:30])"

Verification

The checker re-ran all 78 cases against each fixture with isequaln and an exact class/size check:

  • the new fixture at d0963be9: 78/78 SAME
  • the old fixture at d0963be9: exactly the 20 target cases DIFF, 58 SAME. The resampling cases 31-78, including the 3-condition ANOVA ones, are unchanged by #977
  • the old fixture at EEGLAB 8ac485f6: 78/78 SAME

Two separate MATLAB sessions wrote files that differ only in the header timestamp. Every byte after the 128-byte header is identical, and all 79 variable blocks are raw-identical.

The new values were compared with eegprep's Python statcond (develop d1b85272 statistics code, run from worktree e606f2b1, whose statistics code is identical). This used the double values eegprep computes internally. eegprep's MATLAB-compatible output still casts ANOVA F/p to float32. df matches exactly in every case. Classes are now double for F and p (previously single); df was already double.

The table is the max abs and max rel diff over all elements, with the rel diff also in units of double eps. "bit-equal" counts elements that are identical bit for bit.

case n F max abs F max rel (eps) F bit-equal p max abs p max rel (eps) min p p bit-equal
3 1 2.00e-15 1.09e-15 (4.9) 0/1 8.33e-17 4.44e-16 (2.0) 1.9e-01 0/1
4 3 4.88e-14 1.89e-14 (85.2) 0/3 3.83e-15 3.71e-14 (166.9) 1.0e-01 0/3
5 1 0.00e+00 0.00e+00 (0.0) 1/1 1.67e-16 1.07e-15 (4.8) 1.6e-01 0/1
6 3 8.88e-16 3.89e-16 (1.8) 1/3 2.04e-14 2.18e-14 (98.0) 1.1e-01 0/3
15 1 4.80e-14 5.66e-15 (25.5) 0/1 6.68e-17 2.62e-14 (117.9) 2.6e-03 0/1
16 10 2.42e-13 8.86e-15 (39.9) 3/10 6.38e-16 5.02e-14 (225.9) 5.6e-07 0/10
17 50 2.74e-13 1.40e-14 (63.1) 28/50 4.81e-16 8.57e-14 (385.8) 1.3e-06 0/50
18 100 2.38e-13 1.86e-14 (83.9) 51/100 6.19e-15 6.63e-14 (298.8) 1.1e-06 0/100
19 1 0.00e+00 0.00e+00 (0.0) 1/1 1.73e-18 1.88e-15 (8.5) 9.2e-04 0/1
20 10 3.55e-15 2.96e-16 (1.3) 7/10 1.39e-16 2.50e-15 (11.3) 2.7e-07 0/10
21 50 3.55e-15 3.78e-16 (1.7) 28/50 6.94e-17 7.72e-15 (34.8) 5.2e-08 0/50
22 100 7.11e-15 3.46e-16 (1.6) 62/100 2.05e-15 1.11e-14 (50.0) 2.1e-07 2/100
23 3 5.98e-12 3.19e-13 (1438.6) 0/3 1.94e-15 1.46e-12 (6555.4) 4.0e-05 0/3
24 30 2.57e-11 3.76e-13 (1694.5) 24/30 2.76e-16 2.99e-12 (13457.7) 3.9e-09 0/30
25 150 1.73e-11 5.65e-13 (2544.4) 123/150 3.62e-16 3.93e-12 (17708.8) 7.4e-09 8/150
26 300 9.31e-11 5.53e-13 (2492.0) 256/300 3.79e-16 4.68e-12 (21089.8) 2.1e-12 13/300
27 3 0.00e+00 0.00e+00 (0.0) 3/3 3.89e-15 9.58e-15 (43.1) 1.4e-08 0/3
28 30 3.55e-15 2.76e-16 (1.2) 25/30 5.94e-15 2.94e-14 (132.5) 3.6e-17 1/30
29 150 2.13e-14 4.25e-16 (1.9) 123/150 6.47e-15 3.72e-14 (167.6) 5.8e-18 0/150
30 300 2.13e-14 4.22e-16 (1.9) 258/300 7.49e-15 4.39e-14 (197.6) 4.4e-16 0/300

For comparison, the old single-precision fixtures were off from these double values by up to 2.6e-4 abs in F (case 16).

  • Cases 3-6, 15-22 and 27-30: F is within about 85 ulp and p within about 390 ulp.
  • Cases 23-26 (2-way repeated measures, anova2rm_cell): F is within 2.5e3 ulp (5.7e-13 rel) and p within 2.1e4 ulp (4.7e-12 rel). This comes from different summation order in the cancelling sums of squares, amplified by fcdf's conditioning. It is still at the double-rounding level, with no sign of single precision.

Recorder

These scripts are not part of the commit. Together they re-record the same cases.

st977_common.m and st977_record.m

st977_common.m

function [inputs, nout] = st977_common(S)
% Inputs as t_statcond.TestClassSetup sees them, and nargout per t_statcond.m.
inputs = S.inputs;
for t = 1:numel(inputs)
    for a = 1:numel(inputs{t})-1
        if ischar(inputs{t}{a}) && strcmp(inputs{t}{a}, 'variance')
            if strcmp(inputs{t}{a+1}, 'homogeneous'), inputs{t}{a+1} = 'homogenous';
            elseif strcmp(inputs{t}{a+1}, 'inhomogeneous'), inputs{t}{a+1} = 'inhomogenous'; end
            break
        end
    end
end
nout = zeros(1, numel(inputs));
src = fileread(fullfile(fileparts(which('t_statcond')), 't_statcond.m'));
tok = regexp(src, 'function test_(\d+)\(testCase\)\s*\[results\{1:(\d+)\}\]', 'tokens');
for k = 1:numel(tok), nout(str2double(tok{k}{1})) = str2double(tok{k}{2}); end
end

st977_record.m

function st977_record(inmat, outmat, cases)
% Re-record expResults.test_N.value for the listed cases only, as
% RegressionTest runs them (rng('default'), corrected inputs, nargout from
% t_statcond.m). inputs, absTol, relTol and every other case are kept.
S = load(inmat); [inputs, nout] = st977_common(S);
for n = cases
    assert(nout(n) > 0, 'only multi-output cases are re-recorded');
    rng('default');
    results = cell(1, nout(n));
    [results{1:nout(n)}] = statcond(inputs{n}{:});
    S.(sprintf('test_%d', n)).value = results;
end
save(outmat, '-struct', 'S', '-v7');
end
Open in Web Open in Cursor 

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@suraj-ranganath
suraj-ranganath marked this pull request as ready for review October 20, 2026 19:40
@suraj-ranganath
suraj-ranganath merged commit fec88f9 into master Oct 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants