Skip to content

Fix jackknife MATLAB compatibility - #511

Open
sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-jackknife-matlab-behavior
Open

sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-jackknife-matlab-behavior

Conversation

@sahilphad07-sudo

@sahilphad07-sudo sahilphad07-sudo commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

jackknife did not correctly handle multiple valid estimator outputs and edge cases. Estimators returning multiple values caused a dimension mismatch, while empty and single-element inputs produced results that differed from MATLAB.

This change updates jackknife to correctly handle multi-output estimators and the empty and single-element input cases.

Before

octave:1> jackknife (@(x) [mean(x); std(x)], [1 2 3])
error: =: nonconformant arguments (op1 is 1x1, op2 is 2x1)

octave:2> jackknife (@mean, [])
ans = [](0x1)

octave:3> jackknife (@mean, 5)
ans = NaN

After

octave:1> jackknife (@(x) [mean(x); std(x)], [1 2 3])

ans =

   2.5000   0.7071
   2.0000   1.4142
   1.5000   0.7071

octave:2> jackknife (@mean, [])
ans =

   NaN

octave:3> jackknife (@mean, 5)
ans =

   5

MATLAB Behavior

>> jackknife (@(x) [mean(x); std(x)], [1 2 3])

ans =

    2.5000    0.7071
    2.0000    1.4142
    1.5000    0.7071

>> jackknife (@mean, [])

ans =

   NaN

>> jackknife (@mean, 5)

ans =

     5

Regression Tests Added

  • Empty input
  • Single-element input
  • Estimator returning multiple values

Test Results

All existing and new jackknife BISTs pass:

PASSES 4 out of 4 tests.

This branch has not been deployed

No deployments
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.

1 participant