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
17
votes
2 answers

MySQL: Get average of time differences?

I have a table called Sessions with two datetime columns: start and end. For each day (YYYY-MM-DD) there can be many different start and end times (HH:ii:ss). I need to find a daily average of all the differences between these start and end times. …
nebs
  • 4,939
  • 9
  • 41
  • 70
17
votes
2 answers

How to get average from set of objects in Django?

I have a simple rating system for a property. You give it a mark out of 5 (stars). The models are defined like this def Property(models.Model) # stuff here def Rating(models.Model) property = models.ForeignKey(Property) stars =…
dotty
  • 40,405
  • 66
  • 150
  • 195
17
votes
2 answers

Getting the average of a certain hour on weekdays over several years in a pandas dataframe

I have an hourly dataframe in the following format over several years: Date/Time Value 01.03.2010 00:00:00 60 01.03.2010 01:00:00 50 01.03.2010 02:00:00 52 01.03.2010 03:00:00 49 . . . 31.12.2013 23:00:00 77 I would like to average…
Markus W
  • 1,451
  • 5
  • 19
  • 32
16
votes
9 answers

find average of an array of objects

I am trying to find the average of just the females in the given array sortArray([ {name:'Sarah', gender:'female', age:25}, {name:'Tom', gender:'male', age:18}, {name:'Tim', gender:'male', age:65}, {name:'Kim', gender:'female',…
Jayson G
  • 163
  • 1
  • 1
  • 5
16
votes
6 answers

Compute the average of all numbers in a list that are 50 or greater?

I want to return a function which gives the average of all the marks which are 50 or more. When I run my code, it always returns an empty list. Here is what I have tried: def get_pass_average(marks): average = [] for count in marks: …
Chiu Chiu
  • 175
  • 1
  • 3
16
votes
8 answers

Calculating Standard Deviation & Variance in C++

So, I've posted a few times and previously my problems were pretty vague. I started C++ this week and have been doing a little project. I'm trying to calculate standard deviation & variance. My code loads a file of 100 integers and puts them into an…
Jack
  • 321
  • 2
  • 5
  • 16
16
votes
3 answers

Counting average on list field

I have list of A, and I want to count average on it's field a. What's the best way to do it? class A { int a; int b; } void f() { var L = new List(); for (int i=0; i<3; i++) { L.Add(new A(){a = i}); } }
Nihau
  • 306
  • 1
  • 1
  • 8
16
votes
6 answers

Average time for datetime list

Looking for fastest solution of time averaging problem. I've got a list of datetime objects. Need to find average value of time (excluding year, month, day). Here is what I got so far: import datetime as dtm def avg_time(times): avg = 0 for…
user2915556
  • 199
  • 1
  • 2
  • 8
16
votes
4 answers

Average over a timeframe with missing data

Assuming a table such as: UID Name Datetime Users 4 Room 4 2012-08-03 14:00:00 3 2 Room 2 2012-08-03 14:00:00 3 3 Room 3 2012-08-03 14:00:00 1 1 Room 1 2012-08-03…
ParoX
  • 5,685
  • 23
  • 81
  • 152
16
votes
3 answers

Average of two angles with wrap around

Possible Duplicate: How do you calculate the average of a set of circular data? I have two angles, a=20 degrees and b=350 degrees. The average of those two angles are 185 degrees. However, if we consider that the maximum angle is 360 degrees and…
Mizipzor
  • 51,151
  • 22
  • 97
  • 138
15
votes
4 answers

Group and average NumPy matrix

Say I have an arbitrary numpy matrix that looks like this: arr = [[ 6.0 12.0 1.0] [ 7.0 9.0 1.0] [ 8.0 7.0 1.0] [ 4.0 3.0 2.0] [ 6.0 1.0 2.0] [ 2.0 5.0 2.0] [ 9.0 4.0 3.0] …
Algorithm
  • 199
  • 1
  • 8
14
votes
2 answers

mysql avg on conditional

is it possible to get the average value for a column, as well as the average value for the same column with a conditional? or simply to combine these two queries into one. SELECT AVG( field ) from table SELECT AVG ( field ) from table where col =…
Eric Pigeon
  • 1,091
  • 2
  • 10
  • 21
14
votes
7 answers

Take the average of two signed numbers in C

Let us say we have x and y and both are signed integers in C, how do we find the most accurate mean value between the two? I would prefer a solution that does not take advantage of any machine/compiler/toolchain specific workings. The best I have…
McCormick
  • 169
  • 1
  • 5
14
votes
3 answers

Weighted average using numpy.average

I have an array: In [37]: bias_2e13 # our array Out[37]: [1.7277990734072355, 1.9718263893212737, 2.469657573252167, 2.869022991373125, 3.314720313010104, 4.232269039271717] The error on each value in the array is: In [38]: bias_error_2e13 #…
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
14
votes
6 answers

How to calculate the average color of a UIImage?

I want to build an app that lets the user select an image and it outputs the "average color". For example, this image: The average color would be a greenish/yellowish color. At the moment, I got this code: // In a UIColor extension public static…
Sweeper
  • 213,210
  • 22
  • 193
  • 313