I want to plot Haar functions, which are defined as:
h_1_0 = function(t){
if ((t >= 0) & (t <= 1/2)){return(1)}
else if ((t >= 1/2) & (t <= 1)){return(-1)}
else{return(0)}
}
Then k-th Haar function is:
h = function(t,n,k){return(2^((n-1)/2) * h_1_0((2^(n-1)) * t - k))}
For example I want to draw h(t,1,1)
, it has to be function:
1, if 1<=t<=3/2
-1, if 3/2 <=t<=2
0, otherwise
So how can I plot k-th functions with fixed k and n in R?