Skip to content

mc: exp keeps the rho grid inside lower_rho and upper_rho - #185

Closed
gitRasheed wants to merge 1 commit into
rasheed/py-sd-cluster-fixesfrom
rasheed/py-mc-exp-bounds
Closed

gitRasheed wants to merge 1 commit into
rasheed/py-sd-cluster-fixesfrom
rasheed/py-mc-exp-bounds

Conversation

@gitRasheed

Copy link
Copy Markdown
Collaborator

R's NNS.MC warped the rho grid with exp about 0: the negative side to the power exp, the positive side to 1/exp. With bounds that don't straddle 0 symmetrically the grid left them: lower_rho = 0.2, upper_rho = 0.8, exp = 2 gave 0.447 to 0.894, and [-0.8, -0.2] gave -0.64 to -0.04. OVVO-Financial/NNS#146 (merged) warps each side of 0, or of the bound nearest 0, within its own span. This slice mirrors it.

Stacked on #184; merge with a merge commit.

Changes

  • _generate_mc_rhos (mc.py) uses R's new warp. The ends stay at the bounds and exp > 1 still moves the grid towards upper_rho. The default [-1, 1] grid is unchanged to the bit.
  • _r_seq dropped a last point that rounding put a hair past stop, so seq(-0.8, -0.2, 0.2) had three points here and four in R. It now clamps the end to stop and uses R's 1e-10 count fuzz, as seq.default does. R's new bounds test needs this; it is a separate parity bug that predates DataFrame point_est / IVs.test columns are matched by position, and declared levels are ignored #146.
  • Before and after, with after equal to R main: [0.2, 0.8] by 0.2, exp 2: 0.894 ... 0.447 -> 0.8, 0.6899, 0.5464, 0.2; [-0.8, -0.2]: -0.04 ... -0.64 -> -0.2, -0.2667, -0.4667, -0.8.

Tests

  • New invariants mirroring R's test-mc-rho-grid.R: the grid's range equals the bounds for [0.2, 0.8], [-0.8, -0.2] and [-0.5, 0.5], R main's grid values for the first two, and the default grid against the old formula for exp 1 and 2.
  • The NNS.MC.grid parity helper in tests/_r.py rebuilds R's grid in an inline script rather than calling NNS.MC. It now carries R main's code; its output for the moved case equals the replicate names of NNS.MC on R main. 1 of its 6 cache entries moves, (-0.5, 0.8, by 0.1, exp 1.5); the other 5 are unchanged. The NNS.MC.stat_summary entries still match.
  • Gates on the top of this stack (rasheed/ss-constant-group, which includes this slice), cache only: native 2935 passed, 4 skipped, 3 xfailed, 2 xpassed. With NNS_DISABLE_NATIVE=1: 2913 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 #146, #147 and #148 mirrors together: SHIP.

Mirrors OVVO-Financial/NNS#146

…ounds)

Mirrors R NNS.MC (OVVO-Financial/NNS mc-exp-bounds). exp warped |rho|
about 0 (negative side to the power exp, positive side to 1/exp), so with
bounds that do not straddle 0 symmetrically the grid left them:
lower_rho=0.2, upper_rho=0.8, exp=2 gave 0.447 to 0.894, and [-0.8, -0.2]
gave -0.64 to -0.04. Each side of 0, or of the bound nearest 0, is now
warped within its own span, so the ends stay at the bounds and exp still
moves the grid towards upper_rho. The default [-1, 1] grid is unchanged
to the bit.

_r_seq dropped a last point that rounding put a hair past stop, so
seq(-0.8, -0.2, 0.2) had three points; it now clamps the end to stop and
uses the 1e-10 count fuzz, as R's seq.default does.

The NNS.MC.grid parity helper rebuilds R's grid in an inline script; it
now carries R main's code (its output equals NNS.MC's replicate names on
R main for the moved case). 1 of its 6 cache entries moves, (-0.5, 0.8,
0.1, exp 1.5); the other 5 are unchanged.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Incorporated through NNS R 14.0 integration #192, merged as bd19c3303222af46da79d8c97f258248eb5674d2. Verified exact head 56101ad038ba5a1360e995025a2a02367b8897ee is an ancestor of main; original commits and authorship are preserved. The integration includes the subsequent R14 compatibility corrections and passed the complete GitHub Python 3.11-3.14 matrix. This supersedes the separate landing, not the work or review history.

@github-actions github-actions Bot closed this Nov 7, 2026
@github-actions
github-actions Bot deleted the rasheed/py-mc-exp-bounds branch November 7, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant