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

Potentially use orthopolynom for more polynomial expansions #286

Closed
DavisVaughan opened this issue Feb 7, 2019 · 5 comments
Closed

Potentially use orthopolynom for more polynomial expansions #286

DavisVaughan opened this issue Feb 7, 2019 · 5 comments
Assignees
Labels
help wanted ❤️ we'd love your help!

Comments

@DavisVaughan
Copy link
Member

Low dependencies. Seems like it has been out for awhile and is well tested. Chebyshev polynomial expansions were requested in the DC workshop.

polynomial.values(chebyshev.c.polynomials( 10, normalized=TRUE ), rnorm(100))
@topepo topepo added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jun 27, 2019
@juliasilge juliasilge added help wanted ❤️ we'd love your help! and removed tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day labels Aug 28, 2020
@topepo
Copy link
Member

topepo commented Nov 8, 2021

This could be an option to step_poly()

@EmilHvitfeldt
Copy link
Member

This is going to be hard to do the call2() way because of how orthopolynom is written (Unless I missing some rlang magic). orthopolynom depends on polynom which needs to be attached to give access to the function polynom().

orthopolynom_wrapper <- function(degree) {
  polynomials <- rlang::call2(
    "chebyshev.c.polynomials",
    n = degree,
    normalized = TRUE,
    .ns = "orthopolynom"
  )
  eval(polynomials)
}

orthopolynom_wrapper(4)
#> Error in polynomial(c(1/sqrt(h.0))): could not find function "polynom"

library(orthopolynom)
#> Loading required package: polynom

orthopolynom_wrapper(4)
#> [[1]]
#> 0.1994711 
#> 
#> [[2]]
#> 0.1410474*x 
#> 
#> [[3]]
#> -0.2820948 + 0.1410474*x^2 
#> 
#> [[4]]
#> -0.4231422*x + 0.1410474*x^3 
#> 
#> [[5]]
#> 0.2820948 - 0.5641896*x^2 + 0.1410474*x^4
orthopolynom::chebyshev.c.polynomials
#> function (n, normalized = FALSE) 
#> {
#>     recurrences <- chebyshev.c.recurrences(n, normalized)
#>     if (normalized) {
#>         h.0 <- 8 * pi
#>         p.0 <- polynomial(c(1/sqrt(h.0)))
#>         polynomials <- orthonormal.polynomials(recurrences, p.0)
#>     }
#>     else polynomials <- orthogonal.polynomials(recurrences)
#>     return(polynomials)
#> }
#> <bytecode: 0x7fe628dd18d0>
#> <environment: namespace:orthopolynom>

@topepo
Copy link
Member

topepo commented Dec 13, 2021

I'd say that we should close the issue. This was a nice to have but we are not going to take on other dependencies for a niche feature.

@EmilHvitfeldt
Copy link
Member

Agree. This feature would be a fairly straightforward for someone to put in an extension package as another step if they really need it.

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted ❤️ we'd love your help!
Projects
None yet
Development

No branches or pull requests

4 participants