average

Get average based on value in another row

喜夏-厌秋 提交于 2019-12-19 04:18:10
问题 I have values in an Excel file like this: QR | QR AVG | val1 | q1 5 q1 3 q1 4 q2 7 q2 9 q3 10 q3 11 q3 12 q3 11 q4 5 q5 5 q5 7 And I would like the QR AVG field to represent the average value partitioned by different QR values. In other words, I'd like to have the following values after my calculation: QR | QR AVG | val1 | q1 4 5 q1 4 3 q1 4 4 q2 8 7 q2 8 9 q3 11 10 q3 11 11 q3 11 12 q3 11 11 q4 5 5 q5 6 5 q5 6 7 Where I don't know the exact number of rows that I will have, and I will be

average of a number of arrays with numpy without considering zero values

痴心易碎 提交于 2019-12-19 04:07:05
问题 I am working on numpy and I have a number of arrays with the same size and shape like: a= [153 186 0 258] b=[156 136 156 0] c=[193 150 950 757] I want to have average of the arrays, but I want the program to ignore the zero values in the computation. So, the resulting array for this example will be: d=[167.333 157.333 553 507.5] this is the result of this computation: d=[(153+156+193)/3 (186+136+150)/3 (156+950)/2 (258+757)/2] . Is it possible to do that? 回答1: >>> import numpy as np >>> a =

R: What are the best functions to deal with concatenating and averaging values in a data.frame?

为君一笑 提交于 2019-12-19 04:06:13
问题 I have a data.frame from this code: my_df = data.frame("read_time" = c("2010-02-15", "2010-02-15", "2010-02-16", "2010-02-16", "2010-02-16", "2010-02-17"), "OD" = c(0.1, 0.2, 0.1, 0.2, 0.4, 0.5) ) which produces this: > my_df read_time OD 1 2010-02-15 0.1 2 2010-02-15 0.2 3 2010-02-16 0.1 4 2010-02-16 0.2 5 2010-02-16 0.4 6 2010-02-17 0.5 I want to average the OD column over each distinct read_time (notice some are replicated others are not) and I also would like to calculate the standard

Query to calculate average time between successive events

流过昼夜 提交于 2019-12-19 03:19:30
问题 My question is about how to write an SQL query to calculate the average time between successive events. I have a small table: event Name | Time stage 1 | 10:01 stage 2 | 10:03 stage 3 | 10:06 stage 1 | 10:10 stage 2 | 10:15 stage 3 | 10:21 stage 1 | 10:22 stage 2 | 10:23 stage 3 | 10:29 I want to build a query that get as an answer the average of the times between stage(i) and stage(i+1). For example, the average time between stage 2 and stage 3 is 5: (3+6+6)/3 = 5 回答1: Aaaaand with a

Cumulative sums, moving averages, and SQL “group by” equivalents in R

给你一囗甜甜゛ 提交于 2019-12-18 13:24:40
问题 What's the most efficient way to create a moving average or rolling sum in R? How do you do the rolling function along with a "group by"? 回答1: While zoo is great, sometimes there are simpler ways. If you data behaves nicely, and is evenly spaced, the embed() function effectively lets you create multiple lagged version of a time series. If you look inside the VARS package for vector auto-regression, you will see that the package author chooses this route. For example, to calculate the 3 period

MATLAB: Averaging time-series data without loops?

拟墨画扇 提交于 2019-12-18 08:58:25
问题 I have measured a handful of variables in 30 minute intervals. Time stamps are available in datevec or datenum format. I want to calculate ... a) ... daily averages and b) ... average values at time x , e.g. temperature at 11:30, temperature at 12:00, etc. averaged over my whole dataset. While this is, more or less, easily done with loops, I wonder if there is an easier / more convenient way to work with time-series, since this is a quite basic task after all? /edit 1: As per request: click

Find the average of two combined columns in sql

旧街凉风 提交于 2019-12-18 05:56:17
问题 I want to find the avg of the total of two columns. I want to count the total of col1 and the total of col2 then find the average(how many different rows they are in). I have managed to come up with a solution in the this sqlfiddle (also see below) is this the best way? I initially thought I would need to use the avg function but couldn't work it out using this. CREATE TABLE test ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, uid INT, col1 INT, col2 INT ) DEFAULT CHARACTER SET utf8 ENGINE

How to calculate average of a variable by hour in R

我与影子孤独终老i 提交于 2019-12-18 05:03:37
问题 I'm having trouble when trying to calculate the average temperature by hour. I have a data frame with date , time (hh:mm:ss p.m./a.m.)and temperature . What I need is to extract the mean temperature by hour in order to plot daily variation of temperature. I'm new to R, but did a try with what I know: I first tried by transforming hours into numbers, then extracting the first two characters, and then to calculate the mean but it didn't work very well. Moreover I have so many files to analize

Implement p-mean in excel

感情迁移 提交于 2019-12-17 21:23:11
问题 I'm spreadsheeting my favorite albums and I'd like the good tracks on the album to count more for its average than the bad songs. I thought about geometric means, but those do the opposite of what I want. I found the p-mean, which approaches the maximum of the dataset as p goes to infinity: Is there any way to implement this formula in only one cell? If p=2, I can use sqrt(sumsq()) but I'm not sure how to implement it if p > 2. It's impractical for me to add adjacent cells in each column. 回答1

Calculating moving average/stdev in SAS?

霸气de小男生 提交于 2019-12-17 19:30:03
问题 Hye guys, I included a screenshot to help clarify my problem: http://i40.tinypic.com/mcrnmv.jpg. I'm trying to calculate some kind of moving average and moving standard deviation. The thing is I want to calculate the coefficients of variation (stdev/avg) for the actual value. Normally this is done by calculating the stdev and avg for the past 5 years. However sometimes there will be observations in my database for which I do not have the information of the past 5 years (maybe only 3, 2 etc).