lawsynth/apps/docs-site/assets/showcase-damped-pendulum.svg
caelum0x 96e0591c88 fix(discovery): make SINDy sparsity scale-invariant
Discovery ran stlsq_standardized (thresholds in RMS-normalized feature
space) but then re-filtered the restored *original-unit* coefficients by
config.sparse.threshold. That defeated the standardization: genuine terms
whose coefficient is small purely because their state carries a large
magnitude (e.g. SIR's beta/N ~ 3e-4 with populations ~1e3) were pruned,
collapsing the law unless the user hand-tuned the threshold to the data
scale. Keep every non-zero term the standardized solver returns.

Fixing that unmasked a second bug: when a threshold prunes every remaining
active term in one step, STLSQ's loop broke on empty support and returned
the pre-prune *dense* fit, so an aggressive threshold silently produced a
denser model. Zero the coefficients when the support drains, matching the
reference STLSQ contract.

- Add regression tests: keeps_scale_small_coefficients_after_standardized_fit
  and threshold_above_every_coefficient_yields_the_empty_model.
- SIR now recovers the S*I interaction at raw population scale (thr 0.02);
  Lorenz/Lotka-Volterra/damped-pendulum recovery unchanged.
- Add a reproducible discovery gallery (examples/discovery-gallery) and a
  site showcase page (docs/showcase) with deterministic observed-vs-recovered
  SVG plots served from the docs site.
- .gitignore: local datasets, scratch worlds, and regenerable run/work dirs.

Workspace: 1653 tests pass; docs-site render stays byte-identical.
2026-08-19 00:34:05 +03:00

15 lines
14 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 380" role="img" aria-label="Damped pendulum (nonlinear, 2-state): observed vs. simulated from the recovered law" font-family="ui-sans-serif,system-ui,sans-serif">
<rect width="760" height="380" fill="#0b1020"/>
<rect x="54" y="20" width="556" height="320" fill="#0f1630" stroke="#26304f"/>
<text x="54" y="368" fill="#8a94b0" font-size="12">time →</text>
<polyline fill="none" stroke="#6ea8fe" stroke-opacity="0.28" stroke-width="6" points="54.00,108.82 56.32,109.42 58.63,111.22 60.95,114.16 63.27,118.21 65.58,123.29 67.90,129.31 70.22,136.15 72.53,143.68 74.85,151.72 77.17,160.10 79.48,168.61 81.80,177.04 84.12,185.19 86.43,192.88 88.75,199.92 91.07,206.18 93.38,211.54 95.70,215.91 98.02,219.23 100.33,221.46 102.65,222.58 104.97,222.59 107.28,221.49 109.60,219.33 111.92,216.14 114.23,211.99 116.55,206.97 118.87,201.17 121.18,194.72 123.50,187.76 125.82,180.46 128.13,173.00 130.45,165.55 132.77,158.30 135.08,151.42 137.40,145.06 139.72,139.36 142.03,134.43 144.35,130.37 146.67,127.25 148.98,125.09 151.30,123.94 153.62,123.80 155.93,124.65 158.25,126.48 160.57,129.23 162.88,132.85 165.20,137.26 167.52,142.36 169.83,148.04 172.15,154.16 174.47,160.59 176.78,167.15 179.10,173.70 181.42,180.08 183.73,186.13 186.05,191.71 188.37,196.70 190.68,201.01 193.00,204.54 195.32,207.23 197.63,209.05 199.95,209.97 202.27,209.99 204.58,209.11 206.90,207.36 209.22,204.80 211.53,201.46 213.85,197.44 216.17,192.83 218.48,187.73 220.80,182.26 223.12,176.56 225.43,170.77 227.75,165.03 230.07,159.48 232.38,154.24 234.70,149.45 237.02,145.20 239.33,141.58 241.65,138.66 243.97,136.50 246.28,135.12 248.60,134.56 250.92,134.80 253.23,135.84 255.55,137.64 257.87,140.15 260.18,143.33 262.50,147.08 264.82,151.32 267.13,155.96 269.45,160.87 271.77,165.93 274.08,171.03 276.40,176.03 278.72,180.82 281.03,185.29 283.35,189.33 285.67,192.85 287.98,195.79 290.30,198.08 292.62,199.68 294.93,200.58 297.25,200.75 299.57,200.20 301.88,198.96 304.20,197.06 306.52,194.54 308.83,191.48 311.15,187.94 313.47,184.01 315.78,179.78 318.10,175.37 320.42,170.88 322.73,166.42 325.05,162.10 327.37,158.02 329.68,154.27 332.00,150.95 334.32,148.11 336.63,145.82 338.95,144.13 341.27,143.07 343.58,142.64 345.90,142.85 348.22,143.69 350.53,145.13 352.85,147.14 355.17,149.65 357.48,152.62 359.80,155.96 362.12,159.59 364.43,163.42 366.75,167.36 369.07,171.32 371.38,175.18 373.70,178.87 376.02,182.30 378.33,185.38 380.65,188.05 382.97,190.25 385.28,191.93 387.60,193.08 389.92,193.65 392.23,193.66 394.55,193.11 396.87,192.02 399.18,190.41 401.50,188.33 403.82,185.84 406.13,182.99 408.45,179.86 410.77,176.53 413.08,173.08 415.40,169.59 417.72,166.14 420.03,162.84 422.35,159.74 424.67,156.92 426.98,154.45 429.30,152.38 431.62,150.75 433.93,149.60 436.25,148.94 438.57,148.79 440.88,149.14 443.20,149.97 445.52,151.27 447.83,152.99 450.15,155.10 452.47,157.53 454.78,160.23 457.10,163.13 459.42,166.16 461.73,169.23 464.05,172.28 466.37,175.24 468.68,178.02 471.00,180.57 473.32,182.84 475.63,184.75 477.95,186.29 480.27,187.41 482.58,188.10 484.90,188.34 487.22,188.14 489.53,187.50 491.85,186.45 494.17,185.01 496.48,183.23 498.80,181.14 501.12,178.81 503.43,176.29 505.75,173.64 508.07,170.93 510.38,168.23 512.70,165.60 515.02,163.11 517.33,160.81 519.65,158.75 521.97,156.99 524.28,155.57 526.60,154.50 528.92,153.81 531.23,153.52 533.55,153.62 535.87,154.10 538.18,154.96 540.50,156.17 542.82,157.68 545.13,159.48 547.45,161.50 549.77,163.69 552.08,166.01 554.40,168.40 556.72,170.78 559.03,173.12 561.35,175.34 563.67,177.40 565.98,179.26 568.30,180.86 570.62,182.18 572.93,183.18 575.25,183.84 577.57,184.17 579.88,184.14 582.20,183.77 584.52,183.06 586.83,182.05 589.15,180.75 591.47,179.21 593.78,177.46 596.10,175.54 598.42,173.51 600.73,171.42 603.05,169.31 605.37,167.24 607.68,165.26 610.00,163.41"/>
<polyline fill="none" stroke="#6ea8fe" stroke-width="1.8" points="54.00,108.82 56.32,109.42 58.63,111.20 60.95,114.12 63.27,118.14 65.58,123.18 67.90,129.16 70.22,135.96 72.53,143.44 74.85,151.45 77.17,159.78 79.48,168.26 81.80,176.67 84.12,184.81 86.43,192.49 88.75,199.55 91.07,205.84 93.38,211.24 95.70,215.66 98.02,219.05 100.33,221.35 102.65,222.55 104.97,222.65 107.28,221.65 109.60,219.59 111.92,216.51 114.23,212.46 116.55,207.54 118.87,201.83 121.18,195.47 123.50,188.58 125.82,181.34 128.13,173.91 130.45,166.48 132.77,159.21 135.08,152.29 137.40,145.87 139.72,140.09 142.03,135.07 144.35,130.89 146.67,127.63 148.98,125.33 151.30,124.02 153.62,123.72 155.93,124.40 158.25,126.06 160.57,128.65 162.88,132.11 165.20,136.37 167.52,141.33 169.83,146.89 172.15,152.93 174.47,159.28 176.78,165.82 179.10,172.36 181.42,178.77 183.73,184.88 186.05,190.56 188.37,195.68 190.68,200.13 193.00,203.83 195.32,206.72 197.63,208.75 199.95,209.88 202.27,210.12 204.58,209.46 206.90,207.93 209.22,205.57 211.53,202.44 213.85,198.60 216.17,194.15 218.48,189.18 220.80,183.82 223.12,178.19 225.43,172.42 227.75,166.67 230.07,161.06 232.38,155.73 234.70,150.81 237.02,146.39 239.33,142.58 241.65,139.44 243.97,137.04 246.28,135.42 248.60,134.60 250.92,134.58 253.23,135.35 255.55,136.90 257.87,139.18 260.18,142.13 262.50,145.68 264.82,149.76 267.13,154.26 269.45,159.07 271.77,164.08 274.08,169.17 276.40,174.21 278.72,179.09 281.03,183.68 283.35,187.88 285.67,191.60 287.98,194.77 290.30,197.31 292.62,199.19 294.93,200.36 297.25,200.82 299.57,200.57 301.88,199.61 304.20,197.98 306.52,195.72 308.83,192.88 311.15,189.54 313.47,185.78 315.78,181.68 318.10,177.34 320.42,172.88 322.73,168.40 325.05,164.01 327.37,159.82 329.68,155.91 332.00,152.39 334.32,149.32 336.63,146.78 338.95,144.80 341.27,143.44 343.58,142.70 345.90,142.60 348.22,143.14 350.53,144.29 352.85,146.02 355.17,148.28 357.48,151.03 359.80,154.18 362.12,157.67 364.43,161.40 366.75,165.30 369.07,169.25 371.38,173.17 373.70,176.96 376.02,180.53 378.33,183.80 380.65,186.69 382.97,189.15 385.28,191.12 387.60,192.57 389.92,193.46 392.23,193.79 394.55,193.55 396.87,192.77 399.18,191.45 401.50,189.64 403.82,187.38 406.13,184.74 408.45,181.77 410.77,178.55 413.08,175.16 415.40,171.69 417.72,168.21 420.03,164.81 422.35,161.58 424.67,158.59 426.98,155.90 429.30,153.58 431.62,151.67 433.93,150.21 436.25,149.24 438.57,148.77 440.88,148.79 443.20,149.32 445.52,150.32 447.83,151.76 450.15,153.62 452.47,155.84 454.78,158.37 457.10,161.14 459.42,164.09 461.73,167.14 464.05,170.21 466.37,173.24 468.68,176.14 471.00,178.86 473.32,181.33 475.63,183.49 477.95,185.30 480.27,186.72 482.58,187.72 484.90,188.28 487.22,188.39 489.53,188.07 491.85,187.32 494.17,186.16 496.48,184.62 498.80,182.75 501.12,180.60 503.43,178.21 505.75,175.66 508.07,172.99 510.38,170.28 512.70,167.59 515.02,164.99 517.33,162.53 519.65,160.29 521.97,158.29 524.28,156.60 526.60,155.25 528.92,154.26 531.23,153.66 533.55,153.44 535.87,153.62 538.18,154.18 540.50,155.11 542.82,156.38 545.13,157.95 547.45,159.79 549.77,161.84 552.08,164.07 554.40,166.40 556.72,168.79 559.03,171.17 561.35,173.49 563.67,175.69 565.98,177.73 568.30,179.55 570.62,181.11 572.93,182.38 575.25,183.34 577.57,183.96 579.88,184.24 582.20,184.17 584.52,183.76 586.83,183.02 589.15,181.97 591.47,180.64 593.78,179.08 596.10,177.30 598.42,175.38 600.73,173.34 603.05,171.24 605.37,169.13 607.68,167.06 610.00,165.09"/>
<rect x="626" y="17" width="16" height="4" fill="#6ea8fe"/>
<text x="648" y="22" fill="#c9d2ea" font-size="12">theta</text>
<polyline fill="none" stroke="#f7a072" stroke-opacity="0.28" stroke-width="6" points="54.00,169.82 56.32,193.86 58.63,217.34 60.95,239.94 63.27,261.35 65.58,281.14 67.90,298.88 70.22,314.05 72.53,326.14 74.85,334.70 77.17,339.36 79.48,339.91 81.80,336.32 84.12,328.77 86.43,317.60 88.75,303.28 91.07,286.35 93.38,267.39 95.70,246.91 98.02,225.43 100.33,203.35 102.65,181.06 104.97,158.88 107.28,137.13 109.60,116.14 111.92,96.23 114.23,77.77 116.55,61.17 118.87,46.85 121.18,35.24 123.50,26.72 125.82,21.61 128.13,20.09 130.45,22.22 132.77,27.91 135.08,36.89 137.40,48.82 139.72,63.25 142.03,79.73 144.35,97.76 146.67,116.90 148.98,136.73 151.30,156.88 153.62,176.98 155.93,196.73 158.25,215.77 160.57,233.78 162.88,250.41 165.20,265.28 167.52,278.04 169.83,288.31 172.15,295.80 174.47,300.25 176.78,301.52 179.10,299.58 181.42,294.52 183.73,286.55 186.05,275.95 188.37,263.10 190.68,248.41 193.00,232.27 195.32,215.10 197.63,197.28 199.95,179.17 202.27,161.12 204.58,143.45 206.90,126.49 209.22,110.56 211.53,96.00 213.85,83.13 216.17,72.28 218.48,63.73 220.80,57.74 223.12,54.48 225.43,54.04 227.75,56.42 230.07,61.52 232.38,69.14 234.70,79.01 237.02,90.83 239.33,104.24 241.65,118.87 243.97,134.38 246.28,150.40 248.60,166.61 250.92,182.68 253.23,198.30 255.55,213.16 257.87,226.95 260.18,239.37 262.50,250.13 264.82,258.96 267.13,265.64 269.45,269.97 271.77,271.85 274.08,271.23 276.40,268.16 278.72,262.74 281.03,255.18 283.35,245.72 285.67,234.64 287.98,222.26 290.30,208.88 292.62,194.85 294.93,180.46 297.25,166.03 299.57,151.86 301.88,138.24 304.20,125.46 306.52,113.78 308.83,103.48 311.15,94.81 313.47,87.97 315.78,83.14 318.10,80.44 320.42,79.94 322.73,81.63 325.05,85.44 327.37,91.24 329.68,98.83 332.00,107.98 334.32,118.44 336.63,129.93 338.95,142.15 341.27,154.83 343.58,167.67 345.90,180.40 348.22,192.75 350.53,204.44 352.85,215.23 355.17,224.86 357.48,233.13 359.80,239.83 362.12,244.79 364.43,247.90 366.75,249.08 369.07,248.33 371.38,245.68 373.70,241.22 376.02,235.11 378.33,227.52 380.65,218.68 382.97,208.82 385.28,198.20 387.60,187.08 389.92,175.71 392.23,164.35 394.55,153.25 396.87,142.66 399.18,132.81 401.50,123.92 403.82,116.20 406.13,109.82 408.45,104.94 410.77,101.68 413.08,100.10 415.40,100.23 417.72,102.05 420.03,105.49 422.35,110.45 424.67,116.76 426.98,124.25 429.30,132.71 431.62,141.93 433.93,151.67 436.25,161.70 438.57,171.80 440.88,181.72 443.20,191.25 445.52,200.17 447.83,208.28 450.15,215.40 452.47,221.36 454.78,226.03 457.10,229.29 459.42,231.07 461.73,231.34 464.05,230.12 466.37,227.45 468.68,223.41 471.00,218.13 473.32,211.77 475.63,204.49 477.95,196.50 480.27,187.97 482.58,179.14 484.90,170.20 487.22,161.36 489.53,152.83 491.85,144.80 494.17,137.44 496.48,130.94 498.80,125.44 501.12,121.06 503.43,117.91 505.75,116.05 508.07,115.51 510.38,116.31 512.70,118.39 515.02,121.70 517.33,126.13 519.65,131.55 521.97,137.81 524.28,144.76 526.60,152.21 528.92,159.98 531.23,167.88 533.55,175.73 535.87,183.35 538.18,190.55 540.50,197.18 542.82,203.08 545.13,208.11 547.45,212.17 549.77,215.16 552.08,217.02 554.40,217.71 556.72,217.22 559.03,215.59 561.35,212.87 563.67,209.14 565.98,204.51 568.30,199.10 570.62,193.07 572.93,186.55 575.25,179.73 577.57,172.75 579.88,165.79 582.20,159.01 584.52,152.58 586.83,146.62 589.15,141.30 591.47,136.72 593.78,132.99 596.10,130.19 598.42,128.39 600.73,127.62 603.05,127.88 605.37,129.16 607.68,131.41 610.00,134.56"/>
<polyline fill="none" stroke="#f7a072" stroke-width="1.8" points="54.00,169.82 56.32,193.77 58.63,217.16 60.95,239.70 63.27,261.04 65.58,280.79 67.90,298.51 70.22,313.70 72.53,325.85 74.85,334.50 77.17,339.29 79.48,340.00 81.80,336.61 84.12,329.27 86.43,318.31 88.75,304.20 91.07,287.48 93.38,268.69 95.70,248.38 98.02,227.02 100.33,205.05 102.65,182.85 104.97,160.73 107.28,139.01 109.60,118.00 111.92,98.04 114.23,79.49 116.55,62.74 118.87,48.20 121.18,36.32 123.50,27.46 125.82,21.95 128.13,20.00 130.45,21.67 132.77,26.89 135.08,35.43 137.40,46.94 139.72,61.01 142.03,77.16 144.35,94.94 146.67,113.87 148.98,133.56 151.30,153.62 153.62,173.69 155.93,193.45 158.25,212.58 160.57,230.74 162.88,247.59 165.20,262.77 167.52,275.91 169.83,286.65 172.15,294.68 174.47,299.73 176.78,301.65 179.10,300.37 181.42,295.96 183.73,288.61 186.05,278.58 188.37,266.23 190.68,251.96 193.00,236.16 195.32,219.25 197.63,201.60 199.95,183.58 202.27,165.54 204.58,147.79 206.90,130.67 209.22,114.49 211.53,99.58 213.85,86.27 216.17,74.88 218.48,65.70 220.80,59.00 223.12,54.97 225.43,53.73 227.75,55.30 230.07,59.61 232.38,66.49 234.70,75.70 237.02,86.94 239.33,99.87 241.65,114.12 243.97,129.36 246.28,145.21 248.60,161.36 250.92,177.47 253.23,193.23 255.55,208.34 257.87,222.49 260.18,235.38 262.50,246.72 264.82,256.23 267.13,263.68 269.45,268.86 271.77,271.63 274.08,271.92 276.40,269.74 278.72,265.19 281.03,258.43 283.35,249.67 285.67,239.20 287.98,227.31 290.30,214.31 292.62,200.53 294.93,186.28 297.25,171.86 299.57,157.58 301.88,143.73 304.20,130.59 306.52,118.44 308.83,107.55 311.15,98.17 313.47,90.53 315.78,84.82 318.10,81.18 320.42,79.71 322.73,80.43 325.05,83.29 327.37,88.20 329.68,94.98 332.00,103.43 334.32,113.30 336.63,124.32 338.95,136.21 341.27,148.69 343.58,161.46 345.90,174.26 348.22,186.80 350.53,198.83 352.85,210.08 355.17,220.30 357.48,229.27 359.80,236.78 362.12,242.64 364.43,246.71 366.75,248.90 369.07,249.16 371.38,247.50 373.70,243.99 376.02,238.75 378.33,231.94 380.65,223.76 382.97,214.44 385.28,204.22 387.60,193.36 389.92,182.11 392.23,170.73 394.55,159.47 396.87,148.57 399.18,138.28 401.50,128.82 403.82,120.41 406.13,113.23 408.45,107.46 410.77,103.24 413.08,100.65 415.40,99.75 417.72,100.56 420.03,103.02 422.35,107.06 424.67,112.55 426.98,119.33 429.30,127.20 431.62,135.96 433.93,145.39 436.25,155.26 438.57,165.33 440.88,175.38 443.20,185.18 445.52,194.51 447.83,203.17 450.15,210.95 452.47,217.69 454.78,223.23 457.10,227.44 459.42,230.22 461.73,231.51 464.05,231.31 466.37,229.62 468.68,226.51 471.00,222.08 473.32,216.47 475.63,209.81 477.95,202.31 480.27,194.14 482.58,185.51 484.90,176.63 487.22,167.71 489.53,158.94 491.85,150.53 494.17,142.66 496.48,135.52 498.80,129.27 501.12,124.05 503.43,119.97 505.75,117.14 508.07,115.60 510.38,115.39 512.70,116.50 515.02,118.88 517.33,122.45 519.65,127.12 521.97,132.74 524.28,139.17 526.60,146.23 528.92,153.77 531.23,161.58 533.55,169.48 535.87,177.30 538.18,184.84 540.50,191.95 542.82,198.45 545.13,204.20 547.45,209.06 549.77,212.94 552.08,215.74 554.40,217.40 556.72,217.89 559.03,217.22 561.35,215.41 563.67,212.53 565.98,208.66 568.30,203.90 570.62,198.40 572.93,192.29 575.25,185.72 577.57,178.86 579.88,171.88 582.20,164.93 584.52,158.19 586.83,151.80 589.15,145.91 591.47,140.65 593.78,136.16 596.10,132.52 598.42,129.81 600.73,128.10 603.05,127.42 605.37,127.77 607.68,129.13 610.00,131.45"/>
<rect x="626" y="39" width="16" height="4" fill="#f7a072"/>
<text x="648" y="44" fill="#c9d2ea" font-size="12">omega</text>
<text x="626" y="78" fill="#8a94b0" font-size="11">thick = observed</text>
<text x="626" y="94" fill="#8a94b0" font-size="11">thin = recovered law</text>
</svg>