Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERFORMANCE] Improve speed of basis creation #12

Open
schalkdaniel opened this issue Jul 9, 2022 · 1 comment
Open

[PERFORMANCE] Improve speed of basis creation #12

schalkdaniel opened this issue Jul 9, 2022 · 1 comment

Comments

@schalkdaniel
Copy link
Owner

The creation of the sparse spline basis is relatively slow ... Even the splines package does a better job:

x = rnorm(1000000)
knots = cpsp::createKnots(x, 20, 3)

microbenchmark::microbenchmark(
  "cpsp dense" = cpsp::createSplineBasis(x, 3, knots),
  "cpsp sparse" = cpsp::createSparseSplineBasis(x, 3, knots),
  "splines" = splines::splineDesign(knots, x, 3),
  times = 10L
)
Unit: milliseconds
        expr      min       lq     mean   median       uq      max neval
  cpsp dense 199.2278 202.1108 214.4688 212.5961 223.2443 247.3064    10
 cpsp sparse 660.2923 670.0172 706.4031 698.2099 729.9389 778.1298    10
     splines 411.2596 422.8083 465.0356 436.3086 480.1230 582.4038    10
@schalkdaniel
Copy link
Owner Author

> x = rnorm(10000000)
> knots = cpsp::createKnots(x, 20, 3)
> microbenchmark::microbenchmark(
+   "cpsp dense" = cpsp::createSplineBasis(x, 3, knots),
+   "cpsp sparse" = cpsp::createSparseSplineBasis(x, 3, knots),
+   "splines" = splines::splineDesign(knots, x, 3),
+   times = 3L
+ )
Unit: seconds
        expr       min        lq      mean    median        uq      max neval
  cpsp dense  3.121988  3.645907  8.329768  4.169826 10.933658 17.69749     3
 cpsp sparse 11.856646 21.080500 35.757951 30.304355 47.708604 65.11285     3
     splines  4.204505  5.765732  7.817818  7.326959  9.624474 11.92199     3

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

No branches or pull requests

1 participant