cumulative-sum

GNUPLOT: saving data from smooth cumulative

痞子三分冷 提交于 2019-12-09 06:54:58
问题 I make this simple cumulative and histogram plot of a uniform random distribution of real numbers (n=1000): http://www.filedropper.com/random1_1: random1.dat And the macro is: unset key clear reset n=120 #number of intervals max=4. #max value min=1. #min value width=(max-min)/n #interval width #function used to map a value to the intervals bin(x,width)=width*floor(x/width)+width/2.0 # cosi viene centrato in mezzo set xtics min,(max-min)/10,max set boxwidth width set style fill solid 0.5

How to make a cumulative sequence?

大憨熊 提交于 2019-12-08 14:42:25
问题 Say I have a lazy sequence like the following: (def s (iterate inc 1)) (take 10 s) => (1 2 3 4 5 6 7 8 9 10) Now, I want to generate a sequence of cumulative sum of s like the following: => (1 3 6 10 15 ...) How can I do this? What I tried is to use atom and accumulate the sum to it(mutating) Is this the only way to generate cumulative sequence or is there a better way to do this? NOTE: the above cumulative sum is only an example. The source sequence can be other sequence. So I can't use

Bounded cumulative sum in SQL

放肆的年华 提交于 2019-12-08 12:18:18
问题 How can I use SQL to compute a cumulative sum over a column, so that the cumulative sum always stays within upper/lower bounds. Example with lower bound -2 and upper bound 10, showing the regular cumulative sum and the bounded cumulative sum. id input ------------- 1 5 2 7 3 -10 4 -10 5 5 6 10 Result: id cum_sum bounded_cum_sum --------------------------------- 1 5 5 2 12 10 3 2 0 4 -8 -2 5 -3 3 6 7 10 See https://codegolf.stackexchange.com/questions/61684/calculate-the-bounded-cumulative-sum

Cumulative count of values in R

感情迁移 提交于 2019-12-07 09:44:21
问题 I hope you are doing very well. I would like to know how to calculate the cumulative sum of a data set with certain conditions. A simplified version of my data set would look like: t id A 22 A 22 R 22 A 41 A 98 A 98 A 98 R 98 A 46 A 46 R 46 A 46 A 46 A 46 R 46 A 46 A 12 R 54 A 66 R 13 A 13 A 13 A 13 A 13 R 13 A 13 Would like to make a new data set where, for each value of "id", I would have the cumulative number of times that each id appears , but when t=R I need to restart the counting e.g.

Cumulative mean with conditionals

十年热恋 提交于 2019-12-07 08:10:05
问题 New to R. Small rep of my df: PTS_TeamHome <- c(101,87,94,110,95) PTS_TeamAway <- c(95,89,105,111,121) TeamHome <- c("LAL", "HOU", "SAS", "MIA", "LAL") TeamAway <- c("IND", "LAL", "LAL", "HOU", "NOP") df <- data.frame(cbind(TeamHome, TeamAway,PTS_TeamHome,PTS_TeamAway)) df TeamHome TeamAway PTS_TeamHome PTS_TeamAway LAL IND 101 95 HOU LAL 87 89 SAS LAL 94 105 MIA HOU 110 111 LAL NOP 95 121 Imagine these are the first four games of a season with 1230 games. I want to calculate the cumulative

Conditional running count (cumulative sum) with reset in R (dplyr)

天大地大妈咪最大 提交于 2019-12-06 11:34:21
I'm trying to calculate a running count (i.e., cumulative sum) that is conditional on other variables and that can reset for particular values on another variable. I'm working in R and would prefer a dplyr -based solution, if possible. I'd like to create a variable for the running count, cumulative , based on the following algorithm: Calculate the running count ( cumulative ) within combinations of id and age Increment running count ( cumulative ) by 1 for every subsequent trial where accuracy = 0 , block = 2 , and condition = 1 Reset running count ( cumulative ) to 0 for each trial where

Create cumulative counter variable per-user, with multiple conditions

不想你离开。 提交于 2019-12-06 08:51:50
I need to create a counter variable depending on three other variables. This is an extension question of this one. extension question Consider the situations of multiple consumers place order in Amazon. I want to count the successful order times by each user. If you have placed order successfully, the counter variable self plus one;if it is a failed order, the counter remains the same. Obviously, the counter variable will be depend on the time,order status and user. Please consider the scenario of when t is the same but the order status is different,which does not mean the row is duplicate, it

Pandas: Cumulative sum of one column based on value of another

血红的双手。 提交于 2019-12-06 05:30:46
问题 I am trying to calculate some statistics from a pandas dataframe. It looks something like this: id value conditional 1 10 0 2 20 0 3 30 1 1 15 1 3 5 0 1 10 1 So, I need to calculate the cumulative sum of the column value for each id from top to botom, but only when conditional is 1. So, this should give me something like: id value conditional cumulative sum 1 10 0 0 2 20 0 0 3 30 1 30 1 15 1 15 3 5 0 30 1 10 1 25 So, the sum of id=1 is taken only when conditional=1 in the 4th and 6th row and

running total using windows function in sql has same result for same data

让人想犯罪 __ 提交于 2019-12-05 18:49:09
From every references that I search how to do cumulative sum / running total. they said it's better using windows function, so I did select grandtotal,sum(grandtotal)over(order by agentname) from call but I realize that the results are okay as long as the value of each rows are different. Here is the result : Is There anyway to fix this? You might want to review the documentation on window specifications (which is here ). The default is "range between" which defines the range by the values in the row. You want "rows between": select grandtotal, sum(grandtotal) over (order by agentname rows

Cumulative mean with conditionals

为君一笑 提交于 2019-12-05 12:52:58
New to R. Small rep of my df: PTS_TeamHome <- c(101,87,94,110,95) PTS_TeamAway <- c(95,89,105,111,121) TeamHome <- c("LAL", "HOU", "SAS", "MIA", "LAL") TeamAway <- c("IND", "LAL", "LAL", "HOU", "NOP") df <- data.frame(cbind(TeamHome, TeamAway,PTS_TeamHome,PTS_TeamAway)) df TeamHome TeamAway PTS_TeamHome PTS_TeamAway LAL IND 101 95 HOU LAL 87 89 SAS LAL 94 105 MIA HOU 110 111 LAL NOP 95 121 Imagine these are the first four games of a season with 1230 games. I want to calculate the cumulative points per game (mean) at any given time for the home team and the visiting team. The output would look