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
22
votes
11 answers

Math average with php

Time to test your math skills... I'm using php to find the average of $num1, $num2, $num3 and so on; upto an unset amount of numbers. It then saves that average to a database. Next time the php script is called a new number is added to the mix. Is…
Marcus
  • 4,400
  • 13
  • 48
  • 64
22
votes
8 answers

How to find an average date/time in the array of DateTime values

If I have an array of DateTime values: List arrayDateTimes; What's the way to find the average DateTime among them? For instance, if I have: 2003-May-21 15:00:00 2003-May-21 19:00:00 2003-May-21 20:00:00 the average should…
c00000fd
  • 20,994
  • 29
  • 177
  • 400
21
votes
2 answers

TSQL - Average of all values in a column that are not zero

I'm in the process of writing a report and am looking to get the average value of an age column. The problem is that not all rows have an age. If the values for the column are 0 2 4 I would want 3 returned, not 2. I can not simply exclude the zero…
Justin808
  • 20,859
  • 46
  • 160
  • 265
21
votes
3 answers

General - Is there a way to calculate an average based off of an existing average and given new parameters for the resulting average?

Lets say, we're calculating averages of test scores: Starting Test Scores: 75, 80, 92, 64, 83, 99, 79 Average = 572 / 7 = 81.714... Now given 81.714, is there a way to add a new set of test scores to "extend" this average if you don't know the…
thepip3r
  • 2,855
  • 6
  • 32
  • 38
21
votes
2 answers

Update the average of a continuous sequence of numbers in constant time

How can you add and subtract numbers in an average without having to iterate through the entire list? This can be very useful in many situations. For example to continuously calculate the average of the last X values in a stream, adding two averages…
Sam Olesen
  • 944
  • 2
  • 8
  • 21
21
votes
5 answers

SQL: AVG with NULL Values

As far as I understood, the AVG() function ignores NULL Values. So AVG(4,4,4,4,4,NULL) --> 4 In my case I don't want this to happen. I need a solution like that: AVG(4,4,4,4,4,NULL) --> 3,33 without replacing the NULL values directly in the table…
user3364656
  • 279
  • 2
  • 4
  • 9
21
votes
5 answers

Django ORM how to Round an Avg result

I have a model in which I use Django ORM to extract Avg of values from the table. I want to Round that Avg value, how do I do this? See below I am extracting Avg price from Prices model grouped by date in format YYYY-MM, I want to automatically…
Ami
  • 495
  • 1
  • 4
  • 13
20
votes
3 answers

How to find the average of the differences between all the numbers of a Python List

I have a python list like this, arr = [110, 60, 30, 10, 5] What I need to do is actually find the difference of every number with all the other numbers and then find the average of all those differences. So, for this case, it would first find the…
Asad Hussain
  • 564
  • 2
  • 15
20
votes
5 answers

Generate a random number with max, min and mean(average) in Java

I need to generate random numbers with following properties. Min should be 200 Max should be 20000 Average(mean) is 500. Optional: 75th percentile to be 5000 Definitely it is not uniform distribution, nor gaussian. I need to give some left skewness.…
Fuad Malikov
  • 2,325
  • 18
  • 20
20
votes
7 answers

Convert OptionalDouble to Optional

I have a method that builds a list and I want it to return the average of the list as an Optional value. However, when I calculate the average value using Java 8, I always get the return value as an OptionalDouble. How do I convert OptionalDouble…
000000000000000000000
  • 780
  • 4
  • 15
  • 47
20
votes
18 answers

Average function without overflow exception

.NET Framework 3.5. I'm trying to calculate the average of some pretty large numbers. For instance: using System; using System.Linq; class Program { static void Main(string[] args) { var items = new long[] { …
Ron Klein
  • 9,178
  • 9
  • 55
  • 88
20
votes
4 answers

find average of input to vector c++

I am trying to write a program where the user inputs as many numbers as they want and then the program returns the average of the numbers. So far the program only outputs the last number entered. #include #include #include…
alfiej12
  • 371
  • 3
  • 4
  • 15
19
votes
3 answers

Translate SQL to lambda LINQ with GroupBy and Average

I spend a few hours trying to translate simple SQL to lambda LINQ SELECT ID, AVG(Score) FROM myTable GROUP BY ID Any idea?
Yuri
  • 2,820
  • 4
  • 28
  • 40
18
votes
6 answers

Average of grouped rows in Sql Server

I have an Sql Server Table.. it's something like this: Id ...... Column1 ...... Column2 ```````````````````````````````` 1 ........ 1 ............. 34 2 ........ 1 ............. 44 3 ........ 2 ............. 45 4 ........ 2 .............…
iamserious
  • 5,385
  • 12
  • 41
  • 60
17
votes
4 answers

Get average value from list of dictionary

I have lists of dictionary. Let's say it total = [{"date": "2014-03-01", "value": 200}, {"date": "2014-03-02", "value": 100}{"date": "2014-03-03", "value": 400}] I need get maximum, minimum, average value from it. I can get max and min values with…
Gereltod
  • 2,043
  • 8
  • 25
  • 39