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

rename parameter #227

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ make_function = function(opts){
#' @description Return a seasonal pattern \eqn{S(t)}, a function of the form
#' \deqn{S(t) = c \left(1+\epsilon + \sin\left(\frac{2 \pi (t-\tau)}{365}\right)\right)^p}
#' where \eqn{c} is a normalizing constant, and
#' + \eqn{\epsilon \geq 0} or `floor`
#' + \eqn{\epsilon \geq 0} or `bottom`
#' + \eqn{\tau} or `phase`
#' + \eqn{p} or `pw`
#'
Expand All @@ -49,11 +49,11 @@ make_function = function(opts){
make_function.sin = function(opts){
opts$normit = with(opts, rep(norm, N))
for(i in 1:opts$N){
F1 = with(opts,function(t){(1+abs(floor[i])+sin(2*pi*(t)/365))^pw[i]})
F1 = with(opts,function(t){(1+abs(bottom[i])+sin(2*pi*(t)/365))^pw[i]})
over_year <- integrate(F1, 0, 365)$val
opts$normit[i] <- opts$normit[i]/over_year
}
F2 = with(opts,function(t){(1+abs(floor) + sin(2*pi*(t-phase)/365))^pw*normit})
F2 = with(opts,function(t){(1+abs(bottom) + sin(2*pi*(t-phase+91)/365))^pw*normit})
F3 = function(t){if(length(t) == 1) return(F2(t)) else return(sapply(t, F2))}
return(F3)
}
Expand All @@ -62,18 +62,18 @@ make_function.sin = function(opts){
#' @description Return an object to configure
#' a function [make_function.sin]
#' @param phase the phase for a seasonal function
#' @param floor shape parameter
#' @param bottom shape parameter
#' @param pw shape parameter
#' @param norm the normalization period
#' @param N the length of the vector to return
#' @return a function for seasonality
#' @seealso [make_function.sin]
#' @export
makepar_F_sin = function(phase=0, floor=0, pw=1, norm=365, N=1){
makepar_F_sin = function(phase=0, bottom=0, pw=1, norm=365, N=1){
pars <- list()
class(pars) <- "sin"
pars$phase = checkIt(phase, N)
pars$floor = abs(checkIt(floor, N))
pars$bottom = abs(checkIt(bottom, N))
pars$pw = abs(checkIt(pw, N))
pars$norm = norm
pars$N = N
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ articles:
TraceFunctions: TraceFunctions.html
Understanding_ramp.xds: Understanding_ramp.xds.html
Working: Working.html
last_built: 2025-02-12T05:30Z
last_built: 2025-02-12T18:28Z
urls:
reference: https://dd-harp.github.io/ramp.xds/reference
article: https://dd-harp.github.io/ramp.xds/articles
Expand Down
2 changes: 1 addition & 1 deletion man/make_function.sin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/makepar_F_sin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vignettes/TraceFunctions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $$S(t) = c\left(1 + \epsilon + \sin\left(\frac{2 \pi (t-\tau)}{365}\right)\righ

+ $\tau$ or `phase` sets the timing of the peak

+ $\epsilon \geq 0$ or `floor` is a shape parameter: increasing the values of $\epsilon$ reduces the variance
+ $\epsilon \geq 0$ or `bottom` is a shape parameter: increasing the values of $\epsilon$ reduces the variance

+ $p \geq 0$ or `pw` is a shape parameter.

Expand Down Expand Up @@ -143,8 +143,8 @@ lines(tt, s3[2,], col = "blue")
lines(tt, S2(tt), col = "orange", lty=2)
```
```{r}
p4 <- makepar_F_sin(floor=.5)
p5 <- makepar_F_sin(floor=2)
p4 <- makepar_F_sin(bottom=.5)
p5 <- makepar_F_sin(bottom=2)
p6 <- makepar_F_sin(pw=3)
p7 <- makepar_F_sin(pw=6)
```
Expand Down
Loading