From: jim holtman <jholtman_at_gmail.com>

Date: Sun, 27 Apr 2008 18:27:08 -0400

}

return(gama)

}

e3<-p2(r)

Date: Sun, 27 Apr 2008 18:27:08 -0400

Why are you using 'i' in both of the 'for' loops? The value in the first is overwritten by the second and you will not get the correct answer.

r <- rnorm(1000,0,1)

caminho <- c(1 , 3.2 , 1.2 , 3, 2, 1, 4, 5)
p2<-function(r){

gama=0

for(i in 1:1000){

c=caminho[[4]] for(i in 1:caminho[[3]]+1) { c=c+caminho[[i+3]]*((r[i])^(i-1)) d=(abs(c))*exp(-(x^2/2))} gama=gama + ( d/(h(r[i])) )

}

return(gama)

}

e3<-p2(r)

Also why are you using '[[' to access the vector caminho? You sample program is not complete since 'x' is not defined. Also do you mean '1:caminho[3]+1' or '1:(caminho[3]+1)' in the second for loop. They will give you different answers.

So what is the problem you are trying to solve?

On Sun, Apr 27, 2008 at 5:41 PM, Manoel Santos
<manoelsantos666_at_gmail.com> wrote:

> + > p2<-function(r){

*> + gama=0
**> + for(i in 1:1000){
**> + c=caminho[[4]]
**> + for(i in 1:caminho[[3]]+1) {
**> + c=c+caminho[[i+3]]*((r[i])^(i-1))
**> + d=(abs(c))*exp(-(x^2/2))}
**> + gama=gama + ( d/(h(r[i])) ) }
**> + return(gama)}
*

> > e3<-p2(r) > > OBS: r is a rnorm(1000,0,1) > > > caminho > theta_chapeu f_estrela k a0 a1 a2 a3 > 1 3.2 1.2 3 2 1 4 5 > > > > > question > i wanted gama to be the sum of all.. but i keep getting gama as a array of > 1000 values... > ok r doesn't need u to creat variables and correct themm when needed > but why it corrects gama in this case? > like gama[1] them gama[2]... gama[1000] > > tks guys u are helping me much > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help_at_r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >

-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Sun 27 Apr 2008 - 22:48:31 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 28 Apr 2008 - 00:30:33 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*