Re: [R] strange differences in vector operation versus manual calculation

2012-05-02 Thread Rui Barradas
Hello, > > I must be missing something very obvious, but I just cannot see it. > The hardest to find errors. Wrong manual calculation in t1, powers have precedence right to left and before additions. t1b <- 10^(params[1]-xx)^params[2] t3b <- 1 + t1b t4b <- t2/t3b t5b <- params[4] + t4b all.equal

Re: [R] strange differences in vector operation versus manual calculation

2012-05-02 Thread Petr Savicky
On Wed, May 02, 2012 at 11:42:27AM -0400, Rajarshi Guha wrote: > Hi, I'm running a calculation in two ways. The first way is to employ > vectors and evaluate a function in one go. The second way is to break > down the function into pieces and combine the pieces to the final > answer. > > Algebraic

Re: [R] strange differences in vector operation versus manual calculation

2012-05-02 Thread William Dunlap
Your multistep approach corresponds to the following, which has one more set of parentheses than you used yy <- params[4] + (params[3] - params[4])/((1 + 10^(params[1]-xx))^params[2]) In R lingo, both of your approaches are vectorized and you probably won't find a huge difference in speed betwee