Displaying 2 results from an estimated 2 matches for "alphayx".
Did you mean:
alphax
2005 Aug 23
6
priority of operators in the FOR ( ) statement
...e clock at starttime
starttime <- proc.time()[3];
my.function<-function(x) {
s2<-sqrt(2);
if ((x>=0) & (x<s2)) return(x/2)
else
if ((x>=s2) & (x<1+s2)) return(0.2)
else
if ((x>=1+s2) & (x<1.5+s2)) return(0.6)
else
if ((x>1.5+s2) | (x<0)) return(0)
}
alphayx<-function(y,x) {
fy<-my.function(y)
fx<-my.function(x)
fyx<-fy/fx
# to account for 0/0 division
if (is.na(fyx)) fyx<-0
#fyx<-ifelse(is.na(fyx),0,fyx);
alpha<-min(1,fyx)
return(alpha)
}
sigma<-0.5;
#nr is the number of iterations
nr<-20
x<-numeric(nr);
x[1]<-1;
t<...
2005 Aug 24
0
(Fwd) Re: priority of operators in the FOR ( ) statement
...<-c(0,1,.2,.6,0)[findInterval(x,vec)+1]
pos<-which(y0%in%1)
y0[pos]<-y[pos]
y0
}
vec<-c(0,sqrt(2),sqrt(2)+1,sqrt(2)+1.5)
> x<-rnorm(1000000)
> system.time(my1<-myfun(x,vec))
[1] 1.62 0.05 1.67 NA NA
>
will do it more efficiently.
HTH
Petr
>
> alphayx<-function(y,x) {
> fy<-my.function(y)
> fx<-my.function(x)
> fyx<-fy/fx
> # to account for 0/0 division
> if (is.na(fyx)) fyx<-0
> #fyx<-ifelse(is.na(fyx),0,fyx);
> alpha<-min(1,fyx)
> return(alpha)
> }
>
> sigma<-0.5;
> #nr i...