but you get a different hide with sum vs. cumsum. David is right if you want
the sum of n terms.
> sum(1/(1:100)^2) - pi^2/6
[1] -0.009950167
> sum(1/(1:1000)^2) - pi^2/6
[1] -0.0009995002
etc.
> On Jul 24, 2015, at 7:24 PM, Janh Anni wrote:
>
> Wow! So many (simpler) ways to skin a cat. Th
Wow! So many (simpler) ways to skin a cat. Thanks!
On Fri, Jul 24, 2015 at 8:07 PM, David Winsemius
wrote:
>
> On Jul 24, 2015, at 4:37 PM, Janh Anni wrote:
>
> > Hello Jeff,
> >
> > Thanks a lot. I tried it and see that it prints out the entire 100
> partial
> > sums, so I can take the last v
Thanks Bert!
On Fri, Jul 24, 2015 at 7:57 PM, Bert Gunter wrote:
> Janh:
>
> It sounds like you really need to go through an R tutorial or two
> before posting further, as this is a pretty basic query. Or am I wrong
> about this?
>
> An answer: Just use indexing
>
> cumsum(1/seq_len(100)^2)[seq(
cumsum(1/(1:100)^2)[100]
> On Jul 24, 2015, at 4:37 PM, Janh Anni wrote:
>
> Hello Jeff,
>
> Thanks a lot. I tried it and see that it prints out the entire 100 partial
> sums, so I can take the last value as the partial sum for the first 100
> terms. Would there be any way cumsum can print on
On Jul 24, 2015, at 4:37 PM, Janh Anni wrote:
> Hello Jeff,
>
> Thanks a lot. I tried it and see that it prints out the entire 100 partial
> sums, so I can take the last value as the partial sum for the first 100
> terms. Would there be any way cumsum can print only the nth partial sum,
> i.e.
Janh:
It sounds like you really need to go through an R tutorial or two
before posting further, as this is a pretty basic query. Or am I wrong
about this?
An answer: Just use indexing
cumsum(1/seq_len(100)^2)[seq(10, to = 100,by = 10)] ## keeps every 10th
[1] 1.549768 1.596163 1.612150 1.62024
Hello Jeff,
Thanks a lot. I tried it and see that it prints out the entire 100 partial
sums, so I can take the last value as the partial sum for the first 100
terms. Would there be any way cumsum can print only the nth partial sum,
i.e. the last value in the array, instead of printing the entire
Please reply-all so the mailing list stays in the loop.
cumsum(1/(1:100)^2)
gives you the partial sums up through i=100.
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#
?cumsum
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Enginee
Dear All,
Does anyone know of any R functions that compute partial sums of series?
Thanks in advance!
Janh
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/
Is there any routine/trick in R to compute a convergence series?
__
R-help@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
11 matches
Mail list logo