When thinking about issues #74 and #76, I wanted something that would take a polynomial and change the coefficients. I wanted a way to return the same polynomial but with random coefficients. I can do something like this:
library("mvp")
a <- rmvp()
a
#> mvp object algebraically equal to
#> 3 a b + 3 a^2 e f^3 + 7 a^2 e^2 f + b d^2 + 3 c e + 5 c^4 + 3 f
coeffs(a) <- 2^coeffs(a)
a
#> mvp object algebraically equal to
#> 8 a b + 8 a^2 e f^3 + 128 a^2 e^2 f + 2 b d^2 + 8 c e + 32 c^4 + 8 f
But I wanted to make the coefficients a random large-ish number. My best effort:
library("mvp")
library("disordR")
a <- rmvp()
a
#> mvp object algebraically equal to
#> 7 + 4 a + a b e^2 + 2 a c d e + 4 c^2 d f^2 + 4 d + 3 e f
f <- function(x){disord(sample(50:90, length(x), replace=TRUE),h=hash(x))}
coeffs(a) <- f(coeffs(a))
a
#> mvp object algebraically equal to
#> 68 + 72 a + 68 a b e^2 + 52 a c d e + 83 c^2 d f^2 + 80 d + 60 e f
This seems unnecessarily difficult. I should either make an easier way [note that disordR must be loaded above] or explain why it is a stupid idea.
When thinking about issues #74 and #76, I wanted something that would take a polynomial and change the coefficients. I wanted a way to return the same polynomial but with random coefficients. I can do something like this:
But I wanted to make the coefficients a random large-ish number. My best effort:
This seems unnecessarily difficult. I should either make an easier way [note that
disordRmust be loaded above] or explain why it is a stupid idea.