Vector of cumulative sums in R

前端 未结 1 1432
小鲜肉
小鲜肉 2020-12-12 01:05

I\'m trying to get a vector of cumulative sums, that is, I have:

    # 500 Samples from the U(0,1) Distribution
U<-runif(500,0,1)

# Empty Vector of leng         


        
相关标签:
1条回答
  • 2020-12-12 01:35

    Please correct me if I'm misunderstanding, but I believe you simply want this:

    I <- cumsum(sqrt(1 - U^2))
    

    It is unclear why you want to use for loops.

    0 讨论(0)
提交回复
热议问题