Questions tagged [average]

In mathematics, an average is a measure of the "middle" or "typical" value of a data set. Different types of averages include the arithmetic mean, the median, and the mode.

In the most common case, the data set is a list of numbers. The average of a list of numbers is a single number intended to typify the numbers in the list. If all the numbers in the list are the same, then this number should be used. If the numbers are not the same, the average is calculated by combining the numbers from the list in a specific way and computing a single number as being the average of the list.

Many different descriptive statistics can be chosen as a measure of the central tendency of the data items. These include the arithmetic mean, the median, and the mode. Other statistics, such as the standard deviation and the range, are called measures of spread and describe how spread out the data is.

See also: , ,

5780 questions
11
votes
1 answer

PostreSQL ERROR: Function AVG (character varying) does not exist

I want to calculate the average number from a column in PostgreSQL SELECT AVG(col_name) From TableName It gives me this error: ERROR: function avg (character varying) does not exist LINE 1: SELECT AVG(col_name) ^ HINT: No…
Alex
  • 8,908
  • 28
  • 103
  • 157
10
votes
4 answers

Average from 5 cells if not blank or zero

I need to calculate an average of 5 cells, but if a cell is blank or zero, it should neglect this value. I am not able to get it to work with =AVERAGEIFS(A10;B13;C5;D6;D8;"<>0") Does anyone know the correct way to calculate this?
Matthias Vanb
  • 923
  • 5
  • 14
  • 32
10
votes
6 answers

Find the average of two combined columns in sql

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)…
ak85
  • 4,154
  • 18
  • 68
  • 113
10
votes
2 answers

Faster way of calculating off-diagonal averages in large matrices

I need to calculate the mean of each off-diagonal element in an n × n matrix. The lower and upper triangles are redundant. Here's the code I'm currently using: A <- replicate(500, rnorm(500)) sapply(1:(nrow(A)-1), function(x) mean(A[row(A) ==…
blmoore
  • 1,487
  • 16
  • 31
9
votes
2 answers

Matlab, remove elements from array which are less than average?

Hi I have a problem writing this with Matlab. So Situation : array contains (100, 90, 80, 4, 2, 200) for example. I want to calculate the average of these numbers and after that, only keep numbers that are equal to or larger than the average. Can…
Zalaboza
  • 8,899
  • 16
  • 77
  • 142
9
votes
2 answers

Haskell - How does this average function work?

I found this implementation of the average function: avg :: [Int] -> Int avg = div . sum <*> length How does this work? I looked at the function that was produced as a result of div . sum: (div . sum) :: (Integral a, Foldable t) => t a -> a -> a I…
xilpex
  • 3,097
  • 2
  • 14
  • 45
9
votes
3 answers

How i can take the average of 100 image using opencv?

i have 100 image, each one is 598 * 598 pixels, and i want to remove the pictorial and noise by taking the average of pixels, but if i want to use Adding for "pixel by pixel"then dividing i will write a loop until 596*598 repetitions for one image,…
Karmel Zaidan
  • 153
  • 2
  • 2
  • 11
9
votes
1 answer

Calculate the average value of a mongodb document

Suppose that I have a collection like this: { _id: 1, city: "New York", state: "NY", murders: 328 } { _id: 2, city: "Los Angeles", state: "CA", murders: 328 } ... The collection shows us the number of murders in all cities of USA.…
user1603268
  • 93
  • 1
  • 1
  • 4
9
votes
1 answer

Compute monthly averages from daily data

I have this dataframe "df1" as example which is actually part of a much larger one (15 years): X1 X2 3798 2009-12-29 0 3799 2009-12-30 0 3800 2009-12-31 0 3802 2010-01-02 0 3803…
MB123
  • 501
  • 2
  • 6
  • 12
9
votes
8 answers

How to manipulate arrays. Find the average. Beginner Java

I have a homework assignment and I was wondering if anyone could help me as I am new to Java and programming and am stuck on a question. The question is: The first method finds the average of the elements of an integer array: public double…
user1605782
  • 111
  • 1
  • 2
  • 8
9
votes
5 answers

average numpy array but retain shape

I have a Numpy 3 axis array whose elements are 3 dimensional. I'd like to average them and return the same shape of the array. The normal average function removes the 3 dimensions and replace it with the average (as expected): a = np.array([[[0.1,…
AJP
  • 26,547
  • 23
  • 88
  • 127
8
votes
5 answers

Take Hourly Average in SQL

I have a SQL table with 2 fields: TimeStamp and Value. Below is an excerpt of some of the data. 2005-02-17 13:31:00 2 2005-02-17 13:46:00 3 2005-02-17 14:01:00 1.7 2005-02-17 14:16:00 2.3 2005-02-17 14:31:00 2 2005-02-17…
Andrew
  • 815
  • 2
  • 13
  • 33
8
votes
4 answers

How do I calculate the average values in objects located in an array?

Let's say I have an array like this: [ { "player_id" => 1, "number_of_matches" => 2, "goals" => 5 }, { "player_id" => 2, "number_of_matches" => 4, "goals" => 10 } ] I want to…
Nobita
  • 23,519
  • 11
  • 58
  • 87
8
votes
4 answers

Calculate Exponential Moving Average on a Queue in C#

I have a simple class for calculating the moving average of values I add to it. I use it like this: MovingAverage ma = new MovingAverage(); ma.push(value1); ma.push(value2); ... Console.Writeline(average.Average); //the class public class…
Joshua
  • 3,465
  • 3
  • 28
  • 19
8
votes
2 answers

get average column A based on a range of values in column B

My dataframe has several columns as follows: df1 <- data.frame(A = c(1,2,4), B=c(1,3,1), C=c(1,1,3)) I have two conditions to get average values for column A. Condition 1: I want to get average of column A when B is 1, i.e. only row1 and row2 will…
a83
  • 81
  • 1
  • 1
  • 2