average

awk average same column in multiple files(with certain range)

回眸只為那壹抹淺笑 提交于 2019-12-13 19:07:18
问题 As I said, I got answer from here: AWK multiple files averge However, that is not enough if I have multiple files dummy_0.txt dummy_100.txt dummy_200.txt... dummy_5000.txt ... dummy_50000.txt . I only want to average column 2 of files range from dummy_0.txt to dummy_5000.txt. Instead of doing this: awk '{a[FNR]+=$2;b[FNR]++;}END{for(i=1;i<=FNR;i++)print i,a[i]/b[i];}' dummy_*.txt I need something like where interval is 100 awk '{a[FNR]+=$2;b[FNR]++;}END{for(i=1;i<=FNR;i++)print i,a[i]/b[i];}'

Reshaping EPA wind speed & direction data with dcast in R

戏子无情 提交于 2019-12-13 16:22:16
问题 I am trying to convert long format wind data into wide format. Both wind speed and wind direction are listed within the Parameter.Name column. These values need to be cast by both Local.Site.Name, and Date.Local variables. If there are multiple observations per unique Local.Site.Name + Date.Local row, then I want the mean value of those observations. The built-in argument 'fun.aggregate = mean' works just fine for wind speed, but mean wind direction cannot be computed this way because the

working out an average of the values in a dictionary

Deadly 提交于 2019-12-13 10:22:12
问题 My dictionary as of now is like this: class_1 = {'Bob':[9,5,4,3,3,4], 'John':[5,5,7,3,6], 'Andy':[7,5,6,4,5], 'Harris':[3,4,2,3,2,3,2]} What i am trying to make it look like is this: class_1_average ={'Bob':[average of scores],'John':[average of scores]......... How can i do this so that even when the scores updates the average also updates with it. And is there also a way to find the highest score out of the scores 回答1: try like this: class_1_average = {key: sum(value)/len(value) for key,

average and sum from array in php [closed]

99封情书 提交于 2019-12-13 09:54:35
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . To help re-target a marketing campaign, we need to create a user demography report I want to find the following from the give array pls help me 1) The average age of all male, and female users 2) The average age of male, and female users in each country 3) As we are not targeting

Average using &rest in lisp

ⅰ亾dé卋堺 提交于 2019-12-13 08:47:17
问题 So i was asked to do a function i LISP that calculates the average of any given numbers. The way i was asked to do this was by using the &rest parameter. so i came up with this : (defun average (a &rest b) (cond ((null a) nil) ((null b) a) (t (+ (car b) (average a (cdr b)))))) Now i know this is incorrect because the (cdr b) returns a list with a list inside so when i do (car b) it never returns an atom and so it never adds (+) And that is my first question: How can i call the CDR of a &rest

Conditional MDX Query to calculate sum and average

三世轮回 提交于 2019-12-13 08:28:49
问题 I have a sales(SalesID, GoodsType, GrossSale, AverageSale). I was to write two MDX expression in MS Visual Studio SSAS cube's Calculation tab to calculate Sum of GrossSale and Average of GrossSale where GoodsType is "Food". If someone please write the MDX expression for me? 回答1: In many cases, you rely on the Analysis Services engine to do the summing for you. To get the sum for the measure [GrossSales] for a single attribute member 2 for attribute DataType of dimension Dim , assuming the

XSLT - Selecting Min, Max, and Avg Attribute Values - Need Data from different Levels

会有一股神秘感。 提交于 2019-12-13 08:20:23
问题 I thing my problem is that the attribute is on a couple of nodes down from the node that I need to select. Also, I need to pull values from different levels. Not sure how to construct the XPath. <?xml version="1.0"?> <software_inventory> <software xmlns:xsi="Software.xsd"> <title>Adobe Photoshop</title> <vendor>Adobe</vendor> <category>Graphics</category> <support_platforms> <platform>Windows 7</platform> <platform>Windows 8</platform> <platform>Windows 8.1</platform> <platform>Linux<

conditional average in excel

本秂侑毒 提交于 2019-12-13 07:10:08
问题 I have an excel sheet where these are the columns: % of contract value = c(4,3,5,6) contract type = c("sell", "sell", "sell", "buy") confidence = c(5, 3, 3, 3) . I would like to do a conditional average as follows: take the average of % of contract value but only for rows where contract type = "sell" and confidence = 3 . In other words the answer to this should be (3 + 5)/2 = 4 Is there an easy way to do this in excel???? 回答1: What is the purpose of the c(bla,bla,bla) notation if this is in

Java Averaging Program

£可爱£侵袭症+ 提交于 2019-12-13 06:34:08
问题 Write a class called Average that can be used to calculate average of several integers. It should contain the following methods:  A method that accepts two integer parameters and returns their average.  A method that accepts three integer parameters and returns their average.  A method that accepts two integer parameters that represent a range. Issue an error message and return zero if the second parameter is less than the first one. Otherwise, the method should return the average of the

In R, what would be an alternative to ave(), using some function from apply family?

落花浮王杯 提交于 2019-12-13 05:59:20
问题 I am using ave() function to get minimum of observations with the same factor level: minX = ave(x, list(factorA), FUN=min) I wonder what would be an alternative using some of the functions from apply family? In particular, what would be an alternative to put proper result back in the dataframe? For example, lets have a small data.frame : d = data.frame( x = c(2,3,3,6,5,7,8,8,9,9), factorA = c('a','a','a','a','a','b','b','b','b','b') ) # function ave automatically enables proper filling of