p(i,x)=a0,i+a1,icos(2π/T*x)+b1,isin(2π/T*x)+c1,ix
Where:
T=365
, and a0,i
, a1,i
, b1,i
and c1,i
are parameters and x
is the only value we input.
I'm confused how to write function without when the parameters are unknown
You just write the function for a general i 's
p_gernal <- function(x, a0, a1, b1, c1, t){
a0 + a1 * cos(2*pi/t * x) + b1 * sin(2*pi/t * x) + c1 * x
}
R your x,a0,a1,b1,c1 parameters should be vectors of the same length or of lenth 1
Example
head(p_gernal(x = x, a0 = a0, a1 = a1, b1 = b1, c1 = c1, 365))
[1] 0.0000000000 0.0205558610 0.0000614598 0.0866477574 0.0137448690
So for a fixed index i it is
p_i <- function(x){
p_gernal(x = x, a0 = 0, a1 = 1, b1 = 2, c1 = 3, 365)
}
> p_i(1:5)
[1] 4.034279 7.068251 10.101906 13.135235 16.168228
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.