Repository navigation
meboot: an exactly linear or constant series no longer errors with rho - #188
Closed
gitRasheed wants to merge 1 commit into
Closed
gitRasheed wants to merge 1 commit into
gitRasheed wants to merge 1 commit into
Conversation
…o (R meboot-zero-residuals)
Mirrors R NNS.meboot (OVVO-Financial/NNS meboot-zero-residuals). When the
detrended residuals are all exactly zero there are no ranks to target rho
with, so nns_meboot raised "function cannot be evaluated at initial
parameters" for every rho and type, and so did nns_mc and
nns_ss(confidence_interval=True) on such a series and nns_arma's
prediction interval for an exactly linear forecast. The rho search and
scl_adjustment are now skipped when every residual is zero, and force_clt
when its reference series has sd 0. Any series with a nonzero residual
takes the old path.
Before -> after (= R main):
nns_meboot(1:10, reps=5, rho=0.5) ValueError -> copies of the trend,
means spread by force_clt
nns_meboot(rep(3, 10), rho=0.5) ValueError -> constant columns
nns_mc(1:20, reps=3, by=0.5) ValueError -> 5 finite blocks
nns_arma(1:20, h=5, method="lin", pred_int=0.95)
ValueError -> intervals around 21:25
The parity and ARMA tests that expected the error now check the result.
No cache entry moves.
Contributor
|
Incorporated through NNS R 14.0 integration #192, merged as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
R's
NNS.mebootstopped with "function cannot be evaluated at initial parameters" when a series' detrended residuals were all exactly zero, as for1:10or a constant, because there are no ranks to target rho with. Every rho and type failed, and so didNNS.MC(1:20)andNNS.SS(x, 1:10, confidence.interval = TRUE). OVVO-Financial/NNS#149 (merged) skips the rho targeting andscl.adjustmentin that case, and force.clt when its reference sd is 0. This slice mirrors it.Stacked on #187 (rasheed/ss-constant-group); merge with a merge commit.
Changes
_nns_meboot_one(meboot.py) skips_target_rhoand the scl_adjustment block when every residual is exactly 0, and_force_cltwhensd(clt_ref)is 0. The last guard changes nothing in Python, because_force_cltalready returned the ensemble unchanged when the target means have sd 0. It's there so the code reads like R's. Any series with a nonzero residual takes the old path.nns_meboot(1:10, reps=5, rho=0.5)raised and now gives copies of the trend with their means spread by force_clt.rep(3, 10)gives constant columns.nns_mc(1:20, reps=3, by=0.5)gives 5 finite blocks.nns_arma(1:20, h=5, method="lin", pred_int=0.95)raised and now gives intervals around 21:25 (R main: 21 ± 2.625).nns_mebootdocstring and docs/conventions.md say rho has no effect in this case, as R's Rd now does. The comment in stochastic_superiority.py drops "NNS.meboot cannot rescale it".Tests
1:10at every type and rho in {-1, 0, 0.5, 1}, each replicate is linear to 1e-6 with slope in [1, 1.05], and the sorted replicate means match those of1:10 + 1e-9 * noiseto 1e-6. Also, scl_adjustment gives finite values,reps=1returns x exactly,drift=Falsegives means of 5.5, and the constant series gives constant columns for rho 0.5, nnsdep, scl_adjustment andtarget_drift=0. NNS.SS with a linear group and NNS.MC on1:20give finite results.5.5 + z * sd(x) / sqrt(10). Python's_force_cltstill scales bysqrt(reps). R Inspect R NNS API update 54c98418c2a11499ebb1c456570d2b66c37eb817 #107 changed that tosqrt(n), and the Python side of it waits for the re-vendor. R's constant-series case withtarget_drift = 0and no rho runs in Python with rho 0.5, becausenns_meboot(rho=None)returns{}(that is what R returns when rho = NULL is passed explicitly). R'stscase has no Python counterpart.NNS_DISABLE_NATIVE=1: 2936 passed, 29 skipped, 2 xpassed. The 3 xfails are mode: break tied discrete modes by gravity, not their mean (mirrors R #111) #178's strict ones and the 2 xpasses the existing non-strict live-R VAR xfails. tests/parity/test_practical_examples.py against the usual R library: 9 passed, 2 xfailed, as on mode: break tied discrete modes by gravity, not their mean (mirrors R #111) #178. ruff check is clean on every changed file.Review
GPT-6.1 Sol reviewed the #149 and #132 mirrors together: SHIP, no findings. It checked 198 nonzero-residual meboot cases per backend for bit-identical outputs and RNG state.
Mirrors OVVO-Financial/NNS#149