# [R] Converting from density to cumulative distribution

jim holtman jholtman at gmail.com
Thu Apr 21 17:31:50 CEST 2011

```?cumsum

> x = c(1,3,2,2,5)
> cumsum(x)
[1]  1  4  6  8 13
>

On Thu, Apr 21, 2011 at 11:05 AM, Parodi, Pietro
<Pietro.Parodi at willis.com> wrote:
>
> Hello
>
> I'm trying to do the following vector operation:
>
> given vector x = c(x1,x2,x3,x4...xn),  produce vector y =
> c(x1,x1+x2,x1+x2+x3,...x1+...+xn).
>
> E.g.,  from x = c(1,3,2,2,5), produce y = c(1,4,6,8,13).
>
> The underlying problem is finding the cumulative distribution function
> given the empirical density distribution function.
>
> I have done some research on this but the only relevant thing I've found
> is the function "integrate", which however gives me the sum of the whole
> vector not the step-wise sum.
>
>
> Pietro
>
>
> ______________________________________________________________________
>
> For information pertaining to Willis' email confidentiality and monitoring policy, usage restrictions, or for specific company registration and regulatory status information, please visit http://www.willis.com/email_trailer.aspx
>
> We are now able to offer our clients an encrypted email capability for secure communication purposes. If you wish to take advantage of this service or learn more about it, please let me know or contact your Client Advocate for full details. ~W67897
> ______________________________________________________________________
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

```