fix(fractal-dim): mean log-log slope for box-count, Richardson D for …#358
Open
darkclad wants to merge 2 commits into
Open
fix(fractal-dim): mean log-log slope for box-count, Richardson D for …#358darkclad wants to merge 2 commits into
darkclad wants to merge 2 commits into
Conversation
Author
Justification — golden value changes for
|
| Golden | Old | New | Why |
|---|---|---|---|
FRACT_DIM_BOXCOUNT |
−0.830074998557687 | 1.5849625007211565 | This islog₂(3) = 1.5849625007211562 to ~15 digits — the fixture's box count triples as the scale halves, so the mean log-log slope is exactly log₂3. Squarely inside the valid [1, 2] band. The old value was negative (impossible for a fractal dimension). |
FRACT_DIM_PERIMETER |
−1.97227924244155 | 0.3187149603076458 | D = 1 − slope (Richardson). No external oracle for this fixture — it is a Nyxus-convention regression value — but the old raw-slope value (−1.97) was self-evidently not a dimension. |
Why this is not fudging
FRACT_DIM_BOXCOUNTis self-verifying: the new golden equalslog₂(3)to machine precision, a
value that falls out of the corrected mean-slope definition for this fixture — it was not chosen, it
is what the math gives.- Correctness bound: a 2-D box-counting fractal dimension must lie in
[1, 2]; the old −0.83 was
outside it, the new 1.585 is inside. - Nothing else moved: the fix only touches the two
FRACT_DIM_*outputs; every other shape golden
is unchanged. - Values are byte-identical to the oracle-validated
main-feature-validation(copied, not invented);
only the shared table-merge refactor was dropped.
Regression guard
tests/python/test_feature_bugs.py::test_fractal_dimension_in_range asserts
1.0 <= FRACT_DIM_BOXCOUNT <= 2.0 through the production featurize() path — the hard correctness
band the old code violated. (The C++ oracle assertion for these keys runs at a loose tolerance, so the
Python range check is the tight guard.)
CI
Full suite green on this branch: C++ runAllTests 683/683; pytest tests/python/ 49 passed, 1 skipped.
…perimeter FractalDimensionFeature::calc_lyapunov_slope returned the least-squares slope of the local log(count)/log(scale) slopes against their INDEX (the rate-of-change of the slope, ~0 for a clean power law), so FRACT_DIM_BOXCOUNT came out negative (~-0.83) - outside the valid [1,2] range for a 2D shape. Return the MEAN of the local slopes, which is the box-counting dimension. calculate_perimeter_fdim returned the raw divider-method slope; the Richardson convention is D = 1 - slope. Apply it. Refresh the vetted goldens in test_shape_morphology_2d.h (FRACT_DIM_BOXCOUNT -> 1.5849625007211565 = log2(3); FRACT_DIM_PERIMETER -> 0.3187149603076458; all other shape goldens unchanged) and add tests/python/test_feature_bugs.py::test_fractal_dimension_in_range.
d05f5bc to
2115fd6
Compare
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.
…perimeter
FractalDimensionFeature::calc_lyapunov_slope returned the least-squares slope of the local log(count)/log(scale) slopes against their INDEX (the rate-of-change of the slope,
0 for a clean power law), so FRACT_DIM_BOXCOUNT came out negative (-0.83) - outside the valid [1,2] range for a 2D shape. Return the MEAN of the local slopes, which is the box-counting dimension.calculate_perimeter_fdim returned the raw divider-method slope; the Richardson convention is D = 1 - slope. Apply it.
Refresh the vetted goldens in test_shape_morphology_2d.h (FRACT_DIM_BOXCOUNT -> 1.5849625007211565 = log2(3); FRACT_DIM_PERIMETER -> 0.3187149603076458; all other shape goldens unchanged) and add
tests/python/test_feature_bugs.py::test_fractal_dimension_in_range.