Displaying 2 results from an estimated 2 matches for "thresh1".
Did you mean:
thresh
2013 Sep 13
2
how to get values within a threshold
input:
> values
[1] 0.854400 1.648465 1.829830 1.874704 7.670915 7.673585 7.722619
> thresholds
[1] 1 3 5 7 9
expected output:
[1] 1 4 4 4 7
That is, need a vector of indexes of the maximum value below the threshold.
e.g.
First element is "1", because value[1] is the largest below threshold "1".
Second element is "4", because value[4] is the
2008 Jan 28
0
Grid search: avoid "for" loops thanks to apply&co?
...de into R is inefficient because of the
loops (very slow), a schema of the actual code gives:
for(in in 1:length(thres1))
firstThresh<-tresh1[i]
for(j in 1:length(thres1))
if(j>i)
secondThresh<-tresh1[j]
regime1<-ifelse(x<thresh1)*x
regime2<-ifelse(x>thresh2)*x
...(some matrix algebra in order to obtain the Sum of Squares of
cbind(x, regime1, regime2)
I'm trying to implement it into R with apply&co instead, but don't
succeed. Many packages use grid search but all with &...