Kevin,
Your problem seems to have three restrictions: (1) abs(x[i] - x[i-1]) >=
delta (2) y[i] >= x[i]
and (3) minimize sum(y-x). If this is the case I believe I have a better
solution, with a smaller sum
and in much less time.
The problem is restriction (2). If the diffs are negative you can't su
Kevin,
I'm sorry, but my code has a bug
The correction is:
1) delete the two lines with 'ix'
2) replace them with
for(i in 2:n)
if(abs(x[i] - x[i-1]) < delta) x[i] <- x[i-1] + delta
That's it. The problem is that it's back to slowness.
Sorry, once again,
Rui Barradas
Hello,
I am hoping someone can help tackle the problem below, for which I require a
fast solution. It feels like there should be an elegant approach, but I am
drawing blanks.
Take a vector 'x' with random values > 0:
x = runif(10,1,5)
Assume some reasonably small positive value 'delta':
delt
3 matches
Mail list logo